Hi all!
If I want to create a custom procedure, am I going about it the correct way if I do like this?
DisableCtrls proto :BOOL
....
invoke DisableCtrls,0
....
DisableCtrls proc Enabled:BOOL
invoke EnableWindow,hButton,Enabled;
DisableCtrls endp
Right now it crashes when I call the procedure with the invoke command.
Any help would be greatly appreciated!
This is how i might do this:
EnableCtrls proto :DWORD
....
invoke EnableCtrls, TRUE ; TRUE for enable, FALSE for disable - changed name of function for better understanding of function based on api call below
....
EnableCtrls proc dwEnabledOrDisable:DWORD
invoke EnableWindow, hButton, dwEnabledOrDisable ; last param uses TRUE or FALSE based on win32 documentation, so easier to stick with that for our parameter.
ret ; need return here when coming back out of function, otherwise it might run on into some other function below it
EnableCtrls endp
Cheers! Looks way nicer than my attempt. :) I was missing the ret in the proc... Doh!
Quote from: fearless on January 16, 2015, 05:07:35 AM
This is how i might do this:
EnableCtrls proto :DWORD
....
invoke EnableCtrls, TRUE ; TRUE for enable, FALSE for disable - changed name of function for better understanding of function based on api call below
....
EnableCtrls proc dwEnabledOrDisable:DWORD
invoke EnableWindow, hButton, dwEnabledOrDisable ; last param uses TRUE or FALSE based on win32 documentation, so easier to stick with that for our parameter.
ret ; need return here when coming back out of function, otherwise it might run on into some other function below it
EnableCtrls endp
i rarely use BOOL types, because they're a little confusing
if you look in windows.inc...
bool typedef BYTE
BOOLEAN typedef BYTE
BOOL typedef DWORD
looks like an accident waiting to happen
Yikes! What do you recommend using instead, Dave? Byte or DWORD?
Quote from: dedndave on January 16, 2015, 07:16:52 AM
i rarely use BOOL types, because they're a little confusing
if you look in windows.inc...
bool typedef BYTE
BOOLEAN typedef BYTE
BOOL typedef DWORD
looks like an accident waiting to happen
well - you don't want to use BYTE - the stack should always be 4-aligned for 32-bit code
DWORD is probably the best choice in this case
Ah, true, true. Works like a charm now. :t
Quote from: dedndave on January 16, 2015, 10:55:10 AM
well - you don't want to use BYTE - the stack should always be 4-aligned for 32-bit code
DWORD is probably the best choice in this case