flat assembler
Message board for the users of flat assembler.

flat assembler > Windows > In OpenGL need create window two times.

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 377
For OpenGL need create window two times.
First i create window(window have procWin) and check suport formats.
Then i destroyed first window.

And create second window(window have the same procWin) but PeekMessage(for only second window) send me postquete !
And my program shut down.

My question if i create two windows , did i must registerclassex two times ?
And how correct destroy first window ?

I try two times registerclassex for win1(now procWin1Empty) and win2(proc Win2).
I destroy Win1 (eax=1) but peekmessage get info from Win1(procWin1Empty ) !
But proc Win2 not sending eny message ! And not see MessageBox,0,'Win2', 'Win 2' !
If i pressed Alf+F4 i see messageBox Close(from procWin1Empty)
Code:
proc procWin1Empty  hWnd2, msg2, wParam2, lParam2
              local ps:PAINTSTRUCT
              .if [msg2] = WM_CLOSE
             Msg 'Close'
            ; invoke  PostQuitMessage, 0
             return
             .endif

     .if [msg2] = WM_DESTROY
             Msg 'Destr'
           ;  invoke  PostQuitMessage, 0
             return
     .endif
             invoke  DefWindowProc, [hWnd2], [msg2], [wParam2], [lParam2]
              return
endp         

Code:
proc Win2  hWnd, msg, wParam, lParam
              local ps:PAINTSTRUCT
pusha
     invoke MessageBox,0,'Win2', 'Win 2',0
     popa  
invoke  DefWindowProc, [hWnd], [msg], [wParam], [lParam]
return
    

Get message:
Code:
mov     [msg.message], 1
MaiLoopRender_m:
               cmp [msg.message],WM_QUIT
               jz  ExitWin
               invoke  PeekMessage, addr msg, NULL, 0, 0, PM_REMOVE
               test eax,eax
               jz l1
               invoke  TranslateMessage, addr msg
               invoke  DispatchMessage, addr msg
            l1:  
    


Last edited by Roman on 21 Jan 2018, 13:00; edited 4 times in total
Post 21 Jan 2018, 11:40
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 377
I use CreateWindowEx for create two windows. And two windows have:
wc WNDCLASSEX struct.
And wc2 WNDCLASSEX struct.
I read msdn CreateWindow function in user32 but not see in fasm user32.inc CreateWindowA.
And UnRegisterClassEx.
Post 21 Jan 2018, 11:46
View user's profile Send private message Reply with quote
donn



Joined: 05 Mar 2010
Posts: 114
Did the wndClassEx strucs have unique values? Did registering succeed?

I haven't used 2 Windows, but the following is a slightly annotated Window of mine. It's somewhat hackey, but I was referencing MSDN and just needed something running, so it's not that clean. May spark some ideas:




Code:
        ;struct tagWNDCLASSEX {
        ;  UINT      cbSize;                    ;UINT size 4
        ;  UINT      style;
        ;  WNDPROC   lpfnWndProc;               ;WNDPROC size 8
        ;  int       cbClsExtra;
        ;  int       cbWndExtra;
        ;  HINSTANCE hInstance;                 ;HINSTANCE size 8
        ;  HICON     hIcon;                     ;HICON  size 8
        ;  HCURSOR   hCursor;                   ;HCURSOR  size 8
        ;  HBRUSH    hbrBackground;             ;HBRUSH size 8
        ;  LPCTSTR   lpszMenuName;              ;LPCTSTR  size 8
        ;  LPCTSTR   lpszClassName;
        ;  HICON     hIconSm;                   ;HICON size 8

        mov rdx, 32512                          ; pass IDC_ARROW, MAKEINTRESOURCE(32512)
        mov rcx, 0
        sub rsp, 8*4
        call [LoadCursorA]
        add rsp, 8*4
        mov r12, rax
                

        mov rax, [newWindow.wndClassEx]
        mov qword [rax+0], 50h                          ;cbSize
        mov qword [rax+4], 0                            ;style
        lea r11, [windowMsgs]
        mov qword [rax+8], r11                          ;lpfnWndProc
        mov qword [rax+16], 0                           ;cbClsExtra
        mov qword [rax+20], 0                           ;cbWndExtra
        mov r10, [newWindow.moduleHandle]
        mov qword [rax+24], r10                         ;hInstance
        mov qword [rax+32], 0;r9                                ;hIcon
        mov qword [rax+40], r12                         ;hCursor
        mov qword [rax+48], 0                           ;hbrBackground
        mov qword [rax+56], 0                           ;lpszMenuName
        mov r10, appTitle
        mov qword [rax+64], r10                         ;lpszClassName
        mov qword [rax+72],0;r9                         ;hIconSm

        mov rcx, [newWindow.wndClassEx]
        sub rsp, 8*4
        call [RegisterClassExA]
        add rsp, 8*4

        sub rsp, 8*12
        mov qword [rsp+11*8], 0                         ;lpParam
        mov rcx, [newWindow.moduleHandle]
        mov qword [rsp+10*8],rcx                        ;hInstance
        mov qword [rsp+9*8], 0                          ;hMenu
        mov qword [rsp+8*8], 0                          ;hWndParent
        mov qword [rsp+7*8], 250                        ;nHeight
        mov qword [rsp+6*8], 300                        ;nWidth
        mov qword [rsp+5*8], 200                        ;y
        mov qword [rsp+4*8], 200                        ;x
        mov r9, 13565952                                ;dwStyle        ;0CF0000h
        mov r8, appTitle                                ;lpWindowName
        mov rdx, appTitle                               ;lpClassName
        mov rcx, 0                                      ;dwExStyle
        call [CreateWindowExA]
        add rsp, 8*12
        mov [newWindow.windowHandle], rax

    


Good luck.

https://stackoverflow.com/questions/18835592/win32-two-windows-using-the-same-wndproc-why
Post 21 Jan 2018, 16:11
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 377
Two RegisterClassEx-s work fine.
And two CreateWindowEx-s Win1 and Win2 not get error.
And i see Win1 and Win2
But peekmessage get info from Win1(from procWin1Empty)
Because i press Alt+F4 and see MessageBox 'Close' ! But window Win1 not closed and steel work.
I do four times Alt+F4 and see MessageBox 'Close' always !
Post 21 Jan 2018, 16:18
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 377
I create first Win1 then do Destroy,[hWnd2] (destroy Win1)
Then registre and create Win2 !
Post 21 Jan 2018, 16:19
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 377
I found !
I create two windows with one name !
Two windows have name "OpenGL" !
And PeekMessage for this reason not correct get message from Win2 !
Now work fine !
Post 21 Jan 2018, 18:44
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2018, Tomasz Grysztar.

Powered by rwasa.