News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Sizing a rich edit control???

Started by xandaz, December 31, 2010, 12:50:02 AM

Previous topic - Next topic

xandaz

   Hey guys i'm looking into krichedit controls and found out that i don't know how to size it. It doesnt respond to the size and position CreareParams. I've tried to use CCS_NOPARENTALIGN but doesn't work either. Does anyone know why? If someone knows please help out.

jj2007

Without seeing your (full) code, it is difficult to give an answer. All my richedit controls react as expected to CreateWindowEx params or MoveWindow...

xandaz

   Oks jj... It's kinda taken from your TinyRTF. Here you go. I wanted to put a toolbar on top but then the controls fills the whole client area. Thanks

xandaz

   In the one i sent i used EM_GETRECT. I'm not sure this really works. I tried using GetClientRect and then subtract the height of the toolbar but it didn't work either.

xandaz

   Shit. Sorry, it was the WM_SIZE message. It wasn't considering the Toolbar. Sowwy for my dumb questions. bye

xandaz

    I dont understand why WM_SIZE isnt working. Can someone check it out please? Thanks

jj2007

Perhaps you should check the values you are passing to MoveWindow. If you had MasmBasic,

              deb 1, "MovWin", ToolbarReservedY, eax, ebx

would reveal interesting things. Otherwise, use Olly.

xandaz

   Thing is i changed ToolbarReservedY from local to .data and it works. Do local variables get set by themselves? Thanks jj.

jj2007

Quote from: xandaz on December 31, 2010, 11:56:39 AM
Do local variables get set by themselves?
No, they get set by others. Seriously :8)

dedndave

#9
if you use the LOCAL directive, they are whatever garbage is on the stack
if you define them in .DATA, you determine the value
if you define them in .DATA?, they are whatever is in memory - usually 0's, but you may not always depend on it

i prefer to create my locals by using PUSH, rather than by using LOCAL
well - unless it is a structure or other large array
the downside is, i have to either reference them via something like [EBP-8], or assign names myself by using TEXTEQU

i see some programmers say things like "i don't want to use globals inside a proc"
all the different methods of allocating space are like tools in a toolbox
don't limit yourself by not using all the tools available
use the best tool for the job
whether you allocate space in a segment, on the stack, or dynamically (HeapAlloc etc), it still uses memory - lol
so - what you want to look at:
1) do i want it to be initialized
2) how am i going to address it - by register or by immediate address, etc
locals require the use of LEA/ADDR - defines in segment may use OFFSET
3) does it require code to set it up
if the function is called thousands of times in a session, i may want to use a global allocation, rather than setting up a stack frame
i have to weigh the amount of time it takes to set it up against the time consumed by the rest of the function
4) how is the allocation going to affect the EXE size

jj2007

Quote from: dedndave on December 31, 2010, 01:53:25 PM
if you degine them in .DATA?, they are whatever is in memory - usually 0's, but you may not always depend on it

You could expect garbage for *.com files, but for *.exe you can assume zeroes. The OS loader takes care of that.

dedndave

you caught me on a typo - lol

i guess that is a matter of personal preference
if i want zeros, i either define them in .DATA or, if i define them in .DATA?, i explicitly zero them
is there a document from MS that says otherwise ?

under DOS, i don't think it made a difference whether it was EXE or COM

jj2007

Quote from: dedndave on December 31, 2010, 05:00:45 PM
if i define them in .DATA?, i explicitly zero them
is there a document from MS that says otherwise ?

I have searched a lot but there is nothing official. However, there is no evidence either that anybody ever stumbled over non-zeros in the .data? section, except for .com files of course. Besides, there must be tons of software that rely on this undocumented feature...

dedndave

i read someplace that the HAL zeros unused memory pages when System Idle Process is running
that tells me that, under normal circumstances, you will get zeroed pages
you might have to try really hard to see if it's possible to get a dirty page - lol

FORTRANS

Hi,

  I think the program loader zeroes a program's memory as
it prevents a "security" risk.  Otherwise a program could
obtain information from another program.  And that would
be rather bad in many situations.  Though nothing I checked
says Microsoft does it, it almost has to be done.

Regards,

Steve N.