flat assembler
Message board for the users of flat assembler.

Index > Windows > Dialog resource problem [Newbie]

Author
Thread Post new topic Reply to topic
slacker116



Joined: 18 May 2007
Posts: 12
slacker116
I'm trying to use a dialog in a .rc file and including the .res file but when i run it it doesn't show anything, any thoughts on whats wrong?

main code:
Code:
format PE GUI 4.0
entry start

include "win32a.inc"

IDR_MENU  = 10000
IDM_NEW   = 10002
IDM_EXIT  = 10003
IDM_HELLO = 10005
IDM_ABOUT = 10007
IDD_DLG1  = 1000
IDC_GRP1  = 2005
IDC_HELLO = 2001
IDC_CLEAR = 2002
IDC_EDT1  = 2003

section '.data' data readable writable
  hmain dd ?
  hinst dd ?

  title db 'No 5',0
  classname db 'class51',0
  hello db 'Hello world!',0

section '.code' code readable writeable executable

  start:
    invoke GetModuleHandle,NULL
    mov [hinst],eax
    invoke DialogBoxParam,[hinst],IDD_DLG1,NULL,dlg_proc,NULL
    invoke ExitProcess,0

  proc dlg_proc,hdlg,umsg,wparam,lparam
    push ebx esi edi
    cmp [umsg],WM_COMMAND
    je .wmcommand
    cmp [umsg],WM_CLOSE
    je .wmclose
    cmp [umsg],WM_INITDIALOG
    je .wminitdlg
    jmp .end

    .wminitdlg:
      invoke GetDlgItem,[hdlg],IDC_EDT1
      invoke SetFocus,eax
      jmp .end
    .wmclose:
      invoke EndDialog,[hdlg],0
      jmp .end
    .wmcommand:

    .end:
      pop edi esi ebx
      ret
  endp
section '.idata' import data readable writeable
     library   KERNEL32, 'KERNEL32.DLL',\
            USER32,   'USER32.DLL'

     import    KERNEL32,\
          GetModuleHandle,    'GetModuleHandleA',\
         ExitProcess,        'ExitProcess'


     import    USER32,\
             LoadCursor,         'LoadCursorA',\
              LoadIcon,           'LoadIconA',\
        DialogBoxParam,     'DialogBoxParamA',\
          GetDlgItem,         'GetDlgItem',\
               EndDialog,          'EndDialog',\
        SetFocus,           'SetFocus',\
         MessageBox,         'MessageBoxA',\
              SetDlgItemText,     'SetDlgItemTextA',\
          GetDlgItemText,     'GetDlgItemTextA',\
          SendMessage,        'SendMessageA',\
             PostQuitMessage,    'PostQuitMessage'
section '.rsrc' resource from 'test.rc.res'
    



and my test.rc file:
Code:
#define IDR_MENU 10000
#define IDM_NEW 10002
#define IDM_EXIT 10003
#define IDM_HELLO 10005
#define IDM_ABOUT 10007
#define IDD_DLG1 1000
#define IDC_GRP1 2005
#define IDC_HELLO 2001
#define IDC_CLEAR 2002
#define IDC_EDT1 2003
IDR_MENU MENU
BEGIN
  POPUP "&File"
  BEGIN
    MENUITEM "New\tCtrl+N",IDM_NEW
    MENUITEM "Quit\tCtrl+Q",IDM_EXIT
  END
  POPUP "&Edit"
  BEGIN
    MENUITEM "Say Hello!",IDM_HELLO
  END
  POPUP "&Help",HELP
  BEGIN
    MENUITEM "About",IDM_ABOUT
  END
END
IDD_DLG1 DIALOGEX 6,6,195,83
CAPTION "Super Man"
FONT 8,"MS Sans Serif",0,0
CLASS "MyDialog"
MENU IDR_MENU
STYLE 0x10CF0006
BEGIN
  CONTROL "Say Hello",IDC_HELLO,"Button",0x50010000,138,60,54,13
  CONTROL "Clear",IDC_CLEAR,"Button",0x50010000,104,53,24,11
  CONTROL "",IDC_EDT1,"Edit",0x50010000,16,20,82,44,0x00000200
  CONTROL "Enter Input:",IDC_GRP1,"Button",0x50000007,8,11,124,61
END
    


thanks in advance
Post 20 May 2007, 02:47
View user's profile Send private message Reply with quote
farrier



Joined: 26 Aug 2004
Posts: 274
Location: North Central Mississippi
farrier
slacker116,

Return eax = 1 for windows messages "you" process in your dlg_proc.

hth,

farrier

_________________
Some Assembly Required
It's a good day to code!
U.S.Constitution; Bill of Rights; Amendment 1:
... the right of the people peaceably to assemble, ...
The code is dark, and full of errors!
Post 20 May 2007, 05:46
View user's profile Send private message Reply with quote
slacker116



Joined: 18 May 2007
Posts: 12
slacker116
thanks, i forgot, but after i added that it still doesn't show anything, is the only way to use resources by including it in the source?(the .rsrc section) or am i compiling it wrong? i used the mingw's windres resource compiler
Post 20 May 2007, 20:53
View user's profile Send private message Reply with quote
Yardman



Joined: 12 Apr 2005
Posts: 245
Location: US
Yardman
[ Post removed by author. ]


Last edited by Yardman on 04 Apr 2012, 02:22; edited 1 time in total
Post 20 May 2007, 23:27
View user's profile Send private message Reply with quote
slacker116



Joined: 18 May 2007
Posts: 12
slacker116
Thanks, i knew about that, i was just wondering how/if its possible to use a .res file instead

also, is there a .rc converter to fasm syntax?
Post 24 May 2007, 22:22
View user's profile Send private message Reply with quote
Yardman



Joined: 12 Apr 2005
Posts: 245
Location: US
Yardman
[ Post removed by author. ]


Last edited by Yardman on 04 Apr 2012, 02:22; edited 1 time in total
Post 24 May 2007, 23:34
View user's profile Send private message Reply with quote
slacker116



Joined: 18 May 2007
Posts: 12
slacker116
Awesome, Thanks, Yardman but any ideas why just including .res file doesn't work?
Post 25 May 2007, 00:33
View user's profile Send private message Reply with quote
Yardman



Joined: 12 Apr 2005
Posts: 245
Location: US
Yardman
[ Post removed by author. ]


Last edited by Yardman on 04 Apr 2012, 02:24; edited 2 times in total
Post 25 May 2007, 04:56
View user's profile Send private message Reply with quote
farrier



Joined: 26 Aug 2004
Posts: 274
Location: North Central Mississippi
farrier
slacker116,

The first thing I should have said was: "Check the return value from DialogBoxParam." This may give you the clue you need. It may also be somewhat vague about what you need to do fix your problem.

hth,

farrier

_________________
Some Assembly Required
It's a good day to code!
U.S.Constitution; Bill of Rights; Amendment 1:
... the right of the people peaceably to assemble, ...
The code is dark, and full of errors!
Post 25 May 2007, 06:42
View user's profile Send private message Reply with quote
slacker116



Joined: 18 May 2007
Posts: 12
slacker116
Oh, i forgot the readable flag in the section '.rsrc' line! ok, that fixed it, it works! thanks guys!

but rc-converter doesn't seem to convert the dialog in the .rc file, it does the menu, but not the dialog.

Also, there seems to be no way to specify a menu for the dialog template resource. is this possible?
Post 28 May 2007, 20:35
View user's profile Send private message Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1605
Location: Ukraine
shoorick
you may try this converter: it converts only dialogs from rc, but all other enough simple to write directly in the resource section by hands. it should process menu statements.

here is an example


Description:
Download
Filename: sh551.zip
Filesize: 3.8 KB
Downloaded: 24 Time(s)


_________________
UNICODE forever!
Post 29 May 2007, 05:23
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.