NASM - The Netwide Assembler
Related Projects => NASMX => Topic started by: william427 on August 04, 2014, 05:08:43 PM
-
this is in a res file the top one is for dialog and the second is for button.
my question is does the two numbers have to be 1000 and 1001 or is this any made up numbers?
thanks
#define IDD_DLG1 1000
#define IDC_BTN1 1001
-
Looks like WinAPI issue.
Those looks like made up numbers.
Wikibooks page under the title: "Windows Programming/Resource Script Reference".
Resource Identificator, ID: "IDs are allowed in range 0..65535 and preferred in range 1..32767.".
#define ID_MY_LEG 798
#define ID_MY_SOMETHING_ELSE 6664
#define ID_WHO_CARES_ABOUT_THIS_ID 11233
There are system resources too, like icons, cursors.
* Maybe it (- the range of resource id) depends on resource compiler that you are using.
-
Made up by the programmer, which is what I do.
Each dialog will start with a thousand base:
IDD_MAIN = 1000
IDD_ABOUT = 2000
IDD_OPTIONS = 3000
etc...
And controls on each dialog will go off that base number, i.e. controls on IDD_MAIN will be 1001, 1002, 1003, etc. Controls on IDD_ABOUT will be 2001, 2002, 2003, etc. This will allow about 999 controls on each dialog without clashing with another dialog. Menus might start at 500 and go up. Submenu items will go off that base number: Main menu = 500, subitems will be 501, 502, 503, etc... File menu might be 600 and subitems will be 601, 602, 603, etc...
You as the programmer, will make the rules on how you program.
-
im still having a bit of trouble
without changing the rc file how do I change the caption at run time or is it possible?
thanks
%include "c:\nasm\ini\win32\WIN32N.INC"
IDD_DLG1 equ 1000
IDC_BTN1 equ 1001
MSGhWnd equ 0
MSGmsg equ 4
MSGwParam equ 8
MSGlParam equ 12
EXTERN GetModuleHandleA
IMPORT GetModuleHandleA Kernel32.dll
EXTERN DialogBoxParamA
IMPORT DialogBoxParamA user32.dll
EXTERN MessageBoxA
IMPORT MessageBoxA user32.dll
EXTERN ExitProcess
IMPORT ExitProcess kernel32.dll
section .code USE32
..start:
push dword 0
call [GetModuleHandleA]
mov [mywindowinstance], eax
push dword 0
push dword mydialog
push dword 0
push dword IDD_DLG1
push dword [mywindowinstance]
call [DialogBoxParamA]
mydialog:
cmp dword [esp+4+MSGwParam],1001
je exitout
cmp dword [esp+4+MSGmsg], WM_CLOSE
je exitout
jmp returnback
exitout:
push dword 0
call [ExitProcess]
jmp returnback
testout:
;;push dword MB_OK
;;push dword textinside
;;push dword textinside
;;push dword 0
;;call [MessageBoxA]
returnback:
mov eax, 0
ret 16
section .data USE32
mywindowinstance dd 0
#define IDD_DLG1 1000
#define IDC_BTN1 1001
IDD_DLG1 DIALOGEX 10,10,150,100
STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | DS_CENTERMOUSE | WS_CAPTION
CAPTION "Test_dialog"
FONT 8,"Tahoma"
STYLE WS_VISIBLE|WS_OVERLAPPEDWINDOW
BEGIN
CONTROL "EXIT",IDC_BTN1,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,15,21,39,15
EDITTEXT 206,3,50,100,12,ES_AUTOHSCROLL
END
-
without changing the rc file how do I change the caption at run time or is it possible?
What have you tried? What research have you done? Have you used the Windows API in another language? If so, it is the same here.
You could use SetWindowTextA or SetWindowTextW for Unicode, which eventually just sends the message WM_SETTEXT; so instead of SetWindowText, you could just use SendMessage.
-
its not crashing,but it doesn't put teststring into the box.
is this the right way
thanks
push dword TestString
push dword 0
push dword WM_SETTEXT
push dword 206
push dword [mywindowinstance]
call [SendDlgItemMessageA]
;;SendDlgItemMessageA, dword argv(.hwnd), dword 206, dword WM_SETTEXT, dword 0, dword dwText
-
Have you read the documentation for SendDlgItemMessageA (http://msdn.microsoft.com/en-us/library/windows/desktop/ms645515(v=vs.85).aspx)
LRESULT WINAPI SendDlgItemMessage(
_In_ HWND hDlg,
_In_ int nIDDlgItem,
_In_ UINT Msg,
_In_ WPARAM wParam,
_In_ LPARAM lParam
);
For hDlg, your passing the hInstance of your app! You need to pass the hWnd of your dialog! What does 206 mean for the nIDDlgItem parameter? If you are trying to change the caption for the dialog, this should be IDD_DLG1
-
I have this in my rc file .
later on I have a string of text loaded into this editbox.
the text im loading is longer than the width of the editbox,
ive looked at msdn for an answer,do I se the multyline option?
thanks
ps
I got it put in this by its self>>>ES_MULTILINE<<<
EDITTEXT ED_ONE, 3,3,149,45,ES_AUTOHSCROLL