![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Sep 2011
Posts: 3
Rep Power: 0
![]() |
Hello,
I'm using WinAsm Studio (which uses the MASM assembly language or something) to develop a Win32 x86 application. I'm having trouble adding a button to a dialog... I would like to be able to add, rename, move, hide, show, enable, disable, remove, connect/link, etc. the button dynamically - that's my end goal for now at least. I'll post the code that I think is relevant to my problem: .data firstS db "BUTTON", 0 secondS db "Dont click me", 0 .data? hInstance dword ? dialogInstance HINSTANCE ? styleParams DWORD ? .code
start:
invoke GetModuleHandle, NULL
mov hInstance, eax
invoke DialogBoxParam, hInstance, 101, 0, ADDR DlgProc, 0
invoke ExitProcess, 0
DlgProc proc hWin:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
.if uMsg == WM_INITDIALOG
invoke GetWindowLong, hWin, GWL_HINSTANCE
mov dialogInstance, eax
mov eax, WS_CHILD
add eax, WS_TABSTOP
add eax, WS_VISIBLE
add eax, BS_DEFPUSHBUTTON
mov styleParams, eax
invoke CreateWindowEx, NULL, firstS, secondS, styleParams, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hWin, NULL, dialogInstance, NULL
.elseif uMsg == WM_COMMAND
;.if wParam ==
;.elseif wParam ==
;.endif
.elseif uMsg == WM_CLOSE
invoke EndDialog,hWin,0
.endif
xor eax, eax
ret
DlgProc endp
end startThe rest of the code is pretty much the same as the WinAsm Dialog Base template, minus the static controls and Dialog style... If I comment out everything in the ".if uMsg == WM_INITDIALOG" section (I bolded it above), the program runs successfully and I can see the Dialog as expected. What am I doing wrong? I am new to assembly and Win32 programming, although I've used many different higher level languages and graphics libraries and such so I'm familiar with a few of the concepts. If you could not only help me solve my problem but also help me solve future problems by telling me things like the following, you would be a tremendous help:
Also, there's one more thing that I'm interested in that doesn't relate much to any of my problems or questions above: how do you create custom windows in assembly language that aren't rectangular (e.g. make it resemble a smiley face or something)? I know I've asked a lot of questions, but believe me: I have looked everywhere, read everything, and watched everything to try to find the answers to the questions above. If you don't know the answer to everything or don't feel like answering everything, that's ok. I'd rather at least get some information to help me than get no help at all. Thanks for your help! - Andrew |
|
|
|
|
|
#2 |
|
Achieved Level 70
![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 4,109
Rep Power: 10
![]() ![]() |
Re: Please help with Win32 Dialogs and Controls
>>How do I know when to use HWND, HINSTANCE, DWORD, etc.? Should it always be 100% the same as the parameter type?
Look up the functions (e.g. use google) and the function description will tell you. Yes it should always be the same type. It would be a lot easier for you to first write the program in a higher level language such as C so that you learn how win32 programs work. >>How do I know what registers and such to use? It uses the same registers that all other programs use. To help you see this just write a small snippet in C language then have your C compiler generate an assembly language file. I know vc++ will do it, don't know about others. >>How would I change the style of a dialog window at runtime? You need to read/study a win32 api tutorial. This one is excellent introduction. >>Can I create local variables, and if so, how? You mean to tell us that you are attempting to write a win32 api GUI program in assembly language but know absolutely nothing about assembly language??? Sort of like wanting to swim the English Channel but can't swim a stroke in a swimming pool. >>How would I output the value of a register (such as eax) in a Win32 application? The same way you output text in other languages, use win32 api text functions. >>but I don't know how to convert the value to a string. The same way that you would convert any integer to a string. I'd suggest you first learn how to do it in C language then do it in assembly the same way. That is probably a C Programming 101 assignment. Last edited by Ancient Dragon; Jun 29th, 2012 at 7:04 AM. |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Sep 2011
Posts: 3
Rep Power: 0
![]() |
Re: Please help with Win32 Dialogs and Controls
Thank you. I think you've helped me more than you know.
- Andrew |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| VC++: Refreshing dialog controls | titaniumdecoy | C++ | 7 | Aug 8th, 2006 8:55 PM |
| Tab controls | some1 | C++ | 0 | Apr 17th, 2005 3:28 PM |