Author Topic: res file problems im having  (Read 28396 times)

Offline william427

  • Jr. Member
  • *
  • Posts: 23
res file problems im having
« 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



Code: [Select]
#define IDD_DLG1 1000
#define IDC_BTN1 1001


Offline encryptor256

  • Full Member
  • **
  • Posts: 250
  • Country: lv
  • Win64 .
    • On Youtube: encryptor256
Re: res file problems im having
« Reply #1 on: August 04, 2014, 06:21:22 PM »
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.".

Code: [Select]
#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.
Encryptor256's Investigation \ Research Department.

Offline Gunner

  • Jr. Member
  • *
  • Posts: 74
  • Country: us
    • Gunners Software
Re: res file problems im having
« Reply #2 on: August 05, 2014, 02:53:52 AM »
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.

Offline william427

  • Jr. Member
  • *
  • Posts: 23
Re: res file problems im having
« Reply #3 on: August 08, 2014, 12:25:17 PM »
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



Code: [Select]
%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




Code: [Select]
#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

Offline Gunner

  • Jr. Member
  • *
  • Posts: 74
  • Country: us
    • Gunners Software
Re: res file problems im having
« Reply #4 on: August 08, 2014, 02:25:59 PM »
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.

Offline william427

  • Jr. Member
  • *
  • Posts: 23
Re: res file problems im having
« Reply #5 on: August 09, 2014, 06:46:11 PM »
its not crashing,but it doesn't put teststring into the box.
is this the right way
thanks

Code: [Select]
                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

Offline Gunner

  • Jr. Member
  • *
  • Posts: 74
  • Country: us
    • Gunners Software
Re: res file problems im having
« Reply #6 on: August 10, 2014, 04:54:34 AM »
Have you read the documentation for SendDlgItemMessageA

Code: [Select]
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

Offline william427

  • Jr. Member
  • *
  • Posts: 23
Re: res file problems im having
« Reply #7 on: August 18, 2014, 08:44:31 PM »
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<<<

Code: [Select]
EDITTEXT        ED_ONE,  3,3,149,45,ES_AUTOHSCROLL
« Last Edit: August 18, 2014, 08:50:07 PM by william427 »