News:

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

Create a Flat window with Create WindowEX

Started by hfheatherfox07, May 17, 2012, 07:47:09 PM

Previous topic - Next topic

dedndave

well - that is an extended window style flag that applies to the parent window
you can tell it is an extended flag because of the WS_EX prefix

http://msdn.microsoft.com/en-us/library/windows/desktop/ms632680%28v=vs.85%29.aspx

HWND WINAPI CreateWindowEx(
  __in      DWORD dwExStyle,
  __in_opt  LPCTSTR lpClassName,
  __in_opt  LPCTSTR lpWindowName,
  __in      DWORD dwStyle,
  __in      int x,
  __in      int y,
  __in      int nWidth,
  __in      int nHeight,
  __in_opt  HWND hWndParent,
  __in_opt  HMENU hMenu,
  __in_opt  HINSTANCE hInstance,
  __in_opt  LPVOID lpParam
);

so - the extended style is the first parameter
here is a list with descriptions...
http://msdn.microsoft.com/en-us/library/windows/desktop/ff700543%28v=vs.85%29.aspx
(this link may be found on the page in the first link in the dwExStyle description)

WS_EX_NOINHERITLAYOUT
0x00100000L
The window does not pass its window layout to its child windows.

which more or less implies that it is an extended flag for a parent window   :P

i have never had to use this flag
but - i remember seeing it when i read the documentation   :bg

dedndave

Quote from: RHL on May 19, 2012, 02:51:30 AM
nice code dave  :bg I like it

thanks   :P
but - don't use that code as an example
we were playing around - trying different things   :bg

hfheatherfox07

That is were I thought It went ...so in my example

WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD

LOCAL wc:WNDCLASSEX ; create local variables on stack
LOCAL msg:MSG
LOCAL hwnd:HWND

mov wc.cbSize,SIZEOF WNDCLASSEX ; fill values in members of wc
mov wc.style, WS_EX_NOINHERITLAYOUT   <----------------------------------------------------
mov wc.lpfnWndProc, OFFSET WndProc
mov wc.cbClsExtra,NULL
mov wc.cbWndExtra,NULL
push hInstance
pop wc.hInstance
mov wc.hbrBackground,COLOR_BTNFACE+1 ; COLOR_WINDOW + 9
mov wc.lpszMenuName,NULL
mov wc.lpszClassName,OFFSET ClassName
invoke LoadIcon,NULL,IDI_APPLICATION
mov wc.hIcon,eax
mov wc.hIconSm,eax
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax

invoke RegisterClassEx, addr wc ; register our window class

invoke CreateWindowEx,NULL,ADDR ClassName,ADDR AppName,WS_OVERLAPPEDWINDOW and not WS_MAXIMIZEBOX ,CW_USEDEFAULT,
CW_USEDEFAULT,300,175,NULL,NULL,hInstance,NULL ; Create the window
mov hwnd,eax

invoke ShowWindow, hwnd,SW_SHOWNORMAL ; display our window
invoke UpdateWindow, hwnd

.WHILE TRUE ; The MessageLoop
invoke GetMessage, ADDR msg,NULL,0,0
.BREAK .IF (!eax)
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
.ENDW


mov eax,msg.wParam
ret
WinMain endp

WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM



I tried that but it did not work ......

Do I need to define it in the Constant too ? like with WS_EX_LAYERED


.const
WS_EX_NOINHERITLAYOUT   equ 00100000Lh

dedndave

no
that is a WNDCLASSEX structure member for registering a window class
i.e., that is for class style flags, which begin with CS_
http://msdn.microsoft.com/en-us/library/windows/desktop/ms633577%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/ff729176%28v=vs.85%29.aspx

extended style flags go here...
invoke CreateWindowEx,NULL,ADDR ClassName,ADDR AppName,WS_OVERLAPPEDWINDOW and not WS_MAXIMIZEBOX ,CW_USEDEFAULT,CW_USEDEFAULT,300,175,NULL,NULL,hInstance,NULL

also - this is NOT good   :bg
WS_OVERLAPPEDWINDOW and not WS_MAXIMIZEBOX

hfheatherfox07

Feel free to dispense another doh!!
:bg

dedndave

Heather,
if you have a lot of style flags, do something like this...
StyleFlags = WS_OVERLAPPEDWINDOW or WS_VISIBLE or WS_CLIPCHILDREN
;or WS_HSCROLL or WS_VSCROLL (to add scroll bars to frame window)

   INVOKE  CreateWindowEx,edi,offset szFrameClass,offset szFrameTitle,StyleFlags,
           CW_USEDEFAULT,SW_SHOWNORMAL,MainWidth,MainHeight,edi,edi,ebx,edi


"=" is similar to EQU, except that the symbol may be assigned a different value later in the source
i sometimes use the name "StyleFlags" several times in a source

nah - i wasn't gonna DOH ya, today - lol

hfheatherfox07

I did not even now that was possible  .... I like that  :U

jj2007

Quote from: dedndave on May 19, 2012, 03:37:01 AM
"=" is similar to EQU, except that the symbol may be assigned a different value later in the source

Short example:

include \masm32\include\masm32rt.inc ; CONSOLE ASSEMBLY PLEASE!

int1 equ 123
; int1 equ 456 reassigning numeric values with equ is NOT allowed
int2 = 123
int2 = 456 ; OK with = sign

.code
start:
hw equ <"Hello World">  ; strings can be redefined any time
% print hw, 13, 10 ; needs expansion operator % to work directly
hw equ "Hello Dave" ; the brackets are not needed
% print hw, 13, 10
exit

end start

dedndave

yes - when you assign a string with EQU, the assembler actually makes it a TEXTEQU, which can be reassigned
i like to use them when i make my own stack frames   :P

_ModeControl  TEXTEQU <[EBP+36]> ;signed/unsigned mode control
_OutBufSize   TEXTEQU <[EBP+32]> ;output buffer size in bytes
_OutBufBase   TEXTEQU <[EBP+28]> ;output buffer base address
_InpValSize   TEXTEQU <[EBP+24]> ;input value size in bytes
_InpValBase   TEXTEQU <[EBP+20]> ;input value base address

;                      [EBP+16]   PROC return address
;                      [EBP+12]   saved ESI contents
;                      [EBP+8]    saved EDI contents
;                      [EBP+4]    saved EBX contents
;                      [EBP]      saved EBP contents

_SignXorMask  TEXTEQU <[EBP-4]>  ;sign XOR mask
_OutLastDword TEXTEQU <[EBP-8]>  ;address of last dword in output buffer
;
;
;
        mov     ecx,_InpValBase  ;mov ecx,[ebp+20]


if i like, i can use the same names in the next routine - probably with different strings

jj2007

Quote from: dedndave on May 19, 2012, 08:28:27 AM
when you assign a string with EQU, the assembler actually makes it a TEXTEQU

Where did you get that, programmer's guide? Just curious - the lst file doesn't show any textequ  ::)

dedndave

it just makes sense, is all
EQU is a fixed value - in older versions of MASM, it always resolved to a 16-bit numeric constant
then, they added the TEXTEQU functionality to use strings, and to be "re-usable"
other than the 4 letters, i don't think there is any difference between EQU with a text operand and TEXTEQU

P1

Quote from: dedndave on May 19, 2012, 02:36:19 PMit just makes sense, is all
EQU is a fixed value - in older versions of MASM, it always resolved to a 16-bit numeric constant
then, they added the TEXTEQU functionality to use strings, and to be "re-usable"
other than the 4 letters, i don't think there is any difference between EQU with a text operand and TEXTEQU
One can be re-assigned and the other can not, is my understanding.

Regards,  P1   :8)

jj2007

Quote from: P1 on May 22, 2012, 04:02:18 AM
One can be re-assigned and the other can not, is my understanding.

=, equ and textequ can be re-assigned
What can not be re-assigned is an integer defined with equ or textequ.