News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Rebar Window fails to create | invalid handle

Started by xandaz, November 01, 2020, 03:49:57 AM

Previous topic - Next topic

xandaz

here's the code
__UNICODE__     equ     1
.586
.model flat,stdcall
option casemap:none

WinMain PROTO   :DWORD,:DWORD,:DWORD,:DWORD
WndProc PROTO   :DWORD,:DWORD,:DWORD,:DWORD

include c:\masm32\include\windows.inc
include c:\masm32\include\user32.inc
include c:\masm32\include\kernel32.inc
include c:\masm32\include\comctl32.inc

includelib  c:\masm32\lib\user32.lib
includelib  c:\masm32\lib\kernel32.lib
includelib  c:\masm32\lib\comctl32.lib

include c:\masm32\macros\macros.asm
include ..\winclasses.asm

.const

MainWindowWidth     equ     700
MainWindowHeight    equ     500


.data
hInstance       HINSTANCE       ?
hMainWindow     HWND         ?
wcMain          WNDCLASSEX  <sizeof wcMain,CS_HREDRAW+CS_VREDRAW,offset WndProc,\
                0,0,?,?,?,COLOR_WINDOW,0,offset MainWindowClass,0>
UCSTR           MainWindowClass,"MainWindowClass",0
UCSTR           MainWindowName,"Window",0
iccx            INITCOMMONCONTROLSEX    <sizeof iccx,ICC_COOL_CLASSES+ICC_BAR_CLASSES>
UCSTR           ReBarClass,"ReBarWindow32",0
hReBar          HWND        ?
UCSTR           ReBarName,"ReBar",0
hToolbar        HWND        ?
TBButtons       TBBUTTON <0,100h,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0>
                TBBUTTON      <0,101h,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0>
                TBBUTTON      <0,102h,TBSTATE_ENABLED,TBSTYLE_BUTTON,0,0>


.code
    start: 
        invoke  GetModuleHandle,0
        mov     hInstance,eax
        invoke  InitCommonControlsEx,addr iccx
        invoke  WinMain,hInstance,0,0,SW_SHOWNORMAL
        invoke  ExitProcess,eax

WinMain PROC    hInst:DWORD,hPrevInst:DWORD,CmdLine:DWORD,CmdShow:DWORD

    local   msg:MSG

    invoke  LoadIcon,0,IDI_APPLICATION
    mov     wcMain.hIcon,eax
    mov     wcMain.hIconSm,eax
    invoke  LoadCursor,0,IDC_ARROW
    mov     wcMain.hCursor,eax
    push    hInst
    pop     wcMain.hInstance
    invoke  RegisterClassEx,addr wcMain
    invoke  GetSystemMetrics,SM_CYSCREEN
    shr     eax,1
    sub     eax,MainWindowHeight/2
    push    eax
    invoke  GetSystemMetrics,SM_CXSCREEN
    shr     eax,1
    sub     eax,MainWindowWidth/2
    pop     ebx
    invoke  CreateWindowEx,0,addr MainWindowClass,addr MainWindowName,\
                WS_OVERLAPPEDWINDOW,\
                eax,ebx,MainWindowWidth,MainWindowHeight,\
                0,0,hInst,0
    mov     hMainWindow,eax
    invoke  ShowWindow,eax,CmdShow
    invoke  UpdateWindow,hMainWindow

msg_loop:
    invoke  GetMessage,addr msg,NULL,0,0
    or      eax,eax
    jz      end_msg_loop
    invoke  TranslateMessage,addr msg
    invoke  DispatchMessage,addr msg
    jmp     msg_loop
end_msg_loop:
    mov     eax,msg.wParam
    ret

WinMain endp

WndProc     PROC    hWnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD

    .if     uMsg==WM_DESTROY
        invoke  PostQuitMessage,0
       
    .elseif uMsg==WM_CREATE
        mov     edi,lParam
        .if     [edi.CREATESTRUCT.hwndParent]==NULL

                invoke CreateWindowExW,WS_EX_TOOLWINDOW,addr ReBarClass,addr ReBarName,\
                    WS_VISIBLE+WS_CHILD+RBS_AUTOSIZE+RBS_VERTICALGRIPPER+CCS_NODIVIDER,\
                    0,0,200,40,hWnd,10h,hInstance,0
                mov     hReBar,eax
                invoke  CreateWindowEx,0,WC_TOOLBARWINDOW32,0,WS_VISIBLE+WS_CHILD+TBSTYLE_FLAT,\
                    0,0,MainWindowWidth,40,hReBar,0,hInstance,0
                mov     hToolbar,eax
                invoke  SendMessage,eax,TB_BUTTONSTRUCTSIZE,sizeof TBBUTTON,0
                invoke  SendMessage,hToolbar,TB_ADDBUTTONS,3,addr TBButtons
                invoke  SendMessage,hToolbar,TB_AUTOSIZE,0,0
       .endif                                               
    .else       
        invoke  DefWindowProc,hWnd,uMsg,wParam,lParam
        ret
    .endif
    xor eax,eax
    ret
           

WndProc     endp   

end start

jj2007


xandaz

.data
UCSTR   WC_BUTTON,"Button",0
UCSTR   WC_COMBOBOX,"ComboBox",0
UCSTR   WC_COMBOBOXEX32,"ComboBoxEx32",0
UCSTR   WC_COMBOLBOX,"ComboLBox",0
UCSTR   WC_COMMCTRL_DRAGLISTMSG,"commctrl_DragListMsg",0
UCSTR   WC_CONTROLBAR,"AfxControlBar",0
UCSTR   WC_DDEMLEVENT,"DDEMLEvent",0
UCSTR   WC_DESKTOP,"#32769",0
UCSTR   WC_DIALOGBOX,"#32770",0
UCSTR   WC_EDIT,"Edit",0
UCSTR   WC_HTML_INTERNET_EXPLORER,"HTML_Internet Explorer",0
UCSTR   WC_ICONTITLE,"#32772",0
UCSTR   WC_IE,"Internet Explorer_Server",0
UCSTR   WC_LISTBOX,"ListBox",0
UCSTR   WC_MDICLIENT,"MDIClient",0
UCSTR   WC_MENU,"#32768",0
UCSTR   WC_MESSAGE,"Message",0
UCSTR   WC_MFCDIALOGBAR,"MfcDialogBar",0
UCSTR   WC_MFCFRAME,"MfcFrame",0
UCSTR   WC_MFCMDICHILD,"MfcFrameMDIChild",0
UCSTR   WC_MFCMDIFRAME,"MfcFrameMDI",0
UCSTR   WC_MFCMINIDOCKFRAME,"MfcFrameMiniDock",0
UCSTR   WC_MFCMINIFRAME,"MfcFrameMini",0
UCSTR   WC_MFCSPLITTER,"MfcSplitter",0
UCSTR   WC_MFCVIEW,"MfcView",0
UCSTR   WC_MFCWND,"MfcWnd",0
UCSTR   WC_MSCTLS_HOTKEY32,"msctls_hotkey32",0
UCSTR   WC_MSCTLS_PROGRESS32,"msctls_progress32",0
UCSTR   WC_MSCTLS_STATUSBAR32,"msctls_statusbar32",0
UCSTR   WC_MSCTLS_TRACKBAR32,"msctls_trackbar32",0
UCSTR   WC_MSCTLS_UPDOWN16,"msctls_updown",0
UCSTR   WC_MSCTLS_UPDOWN32,"msctls_updown32",0
UCSTR   WC_MSTASKSWWCLASS, "MSTaskSwWClass"
UCSTR   WC_NATIVEFONTCTL,"NativeFontCtl",0
UCSTR   WC_OCHOST,"OCHost",0
UCSTR   WC_OPENLISTVIEW,"OpenListView",0
UCSTR   WC_REBARWINDOW32,"ReBarWindow32",0
UCSTR   WC_RICHEDIT,"Richedit",0
UCSTR   WC_RICHEDIT20,"RichEdit20W",0
UCSTR   WC_RICHEDIT20A,"RichEdit20a",0
UCSTR   WC_RICHEDIT50W,"RichEdit50W",0
UCSTR   WC_SCROLLBAR,"Scrollbar",0
UCSTR   WC_SHDOCOBJV,"Shell DocObject View",0
UCSTR   WC_SHELLDLLDEFVIEW,"SHELLDLL_DefView",0
UCSTR   WC_SHELLEMBEDDING,"Shell Embedding",0
UCSTR   WC_STATIC,"Static",0
UCSTR   WC_SWITCHWND,"#32771",0
UCSTR   WC_SYSANIMATE32,"SysAnimate32",0
UCSTR   WC_SYSDATETIMEPICK32,"SysDateTimePick32",0
UCSTR   WC_SYSHEADER32,"SysHeader32",0
UCSTR   WC_SYSIPADDRESS32,"SysIPAddress32",0
UCSTR   WC_SYSLINK,"SysLink",0
UCSTR   WC_SYSLISTVIEW32,"SysListView32",0
UCSTR   WC_SYSMONTHCAL32,"SysMonthCal32",0
UCSTR   WC_SYSPAGER,"SysPager",0
UCSTR   WC_SYSTABCONTROL32,"SysTabControl32",0
UCSTR   WC_SYSTREEVIEW32,"SysTreeView32",0
UCSTR   WC_THUMBNAILVIEW,"ThumbnailVwExtWnd32",0
UCSTR   WC_TOOLBARWINDOW32,"ToolbarWindow32",0
UCSTR   WC_TOOLTIPS_CLASS16,"tooltips_class",0
UCSTR   WC_TOOLTIPS_CLASS32,"tooltips_class32",0
UCSTR   WC_TRAYCLOCKWCLASS,"TrayClockWClass",0
UCSTR   WC_TRAYNOTIFYWND,"TrayNotifyWnd",0

xandaz

   Like i said i tried to create a button instead of the rebar control and it worked.

HSE

Rebar is in place, just empty.

Is posible that you don't see nothing until to insert a band?

Equations in Assembly: SmplMath

xandaz


jj2007

invoke  CreateWindowEx,0, addr WC_TOOLBARWINDOW32

It wouldn't hurt if you did some error checking.

xandaz

   yeah....there was king no error. The band  had to be inserted. sorry for making you think

hutch--

Something basic, at a WM_CREATE you can only use the handle supplied in the WndProc, once the CreateWindowEx() has returned you can use its handle as the parent for other controls.