News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Tute 11-2 - Dialogs

Started by RuiLoureiro, July 23, 2008, 03:41:00 PM

Previous topic - Next topic

RuiLoureiro

Hi
       Is there any way to put some text in the window above the EditBox ? How to do it in the resource file ?

In the resource file we have

MyDialog DIALOG 10, 10, 205, 60
STYLE 0x0004 | DS_CENTER | WS_CAPTION | WS_MINIMIZEBOX |
WS_SYSMENU | WS_VISIBLE | WS_OVERLAPPED | DS_MODALFRAME | DS_3DLOOK
CAPTION "Our Second Dialog Box"
BEGIN
    EDITTEXT         IDC_EDIT,   15,17,111,13, ES_AUTOHSCROLL | ES_LEFT
    DEFPUSHBUTTON   "Say Hello", IDC_BUTTON,    141,10,52,13
    PUSHBUTTON      "E&xit", IDC_EXIT,  141,26,52,13
END

       Anyone can help me ?
Thank you
Rui

jj2007

Odd that it doesn't work in the resource file. You can always add this to the DlgProc

   .if iMsg==WM_INITDIALOG
      invoke GetDlgItem,hWnd,IDC_EDIT
      push eax
      invoke SetFocus,eax
      pop eax
      invoke SetWindowText, eax, addr TestString


EDIT:
A workaround:

   CONTROL "Ciao bello", IDC_EDIT, "EDIT", ES_AUTOHSCROLL|ES_LEFT, 15,17,111,13

PBrennick

RuiLoureiro,

Replace ..

    EDITTEXT         IDC_EDIT,   15,17,111,13, ES_AUTOHSCROLL | ES_LEFT

with ...

  CONTROL "This is a test", IDC_EDIT, "Edit", ES_AUTOHSCROLL | ES_LEFT, 15,17,111,13

-- Paul
The GeneSys Project is available from:
The Repository or My crappy website

jj2007

Hi Paul, it seems we had the same idea. Strange that the edit control does not follow the other controls' pattern. In GfaBasic it works that way:

  DIALOG #4,Md_X&,Md_Y&,Md_W&,Md_H&,"Gfw search",WS_THICKFRAME+WS_MINIMIZEBOX+WS_MAXIMIZEBOX+WS_SYSMENU
...
    EDITTEXT "Hello",101,0,0,1,1,StyleEd%

... is a perfectly valid example. So where did this feature get lost???

RuiLoureiro

Hi  jj2007, THANK YOU

               It doesnt work as i want. I dont want to put text inside EditBox BUT OUTSIDE, above

Something like this:
                             Line 10:                       Write your Name:        <-  this is the text i want outside
                                    11:  now come the EDIT BOX

Hi Paul,
             Are you fine ? I hope
             Thank you for your help, too

RuiLoureiro

jj2007


RuiLoureiro

Quote from: jj2007 on July 23, 2008, 06:48:12 PM
Add a STATIC.
Thank you.

      How ?  What is the format of STATIC ?

jj2007

You have two options, see below.

// constants for dialog box
#define IDC_EDIT                                       3000
#define IDC_BUTTON                                     3001
#define IDC_EXIT                                       3002
#define IDC_ROU1                                       3003
#define IDC_ROU2                                       3004
#define DS_CENTER           0x0800L
#define DS_CENTER           0x0800L
#define WS_MINIMIZEBOX      0x00020000L
#define WS_SYSMENU          0x00080000L
#define WS_VISIBLE          0x10000000L
#define WS_OVERLAPPED       0x00000000L
#define DS_MODALFRAME       0x80L
#define DS_3DLOOK           0x0004L
#define WS_CAPTION          0xC00000L
#define ES_AUTOHSCROLL      0x80L
#define ES_LEFT             0

// Constants for menu
#define IDM_EXIT 1
#define IDM_ABOUT 2

FirstMenu MENU
{
POPUP "&File"
        {
         MENUITEM "E&xit",IDM_EXIT
        }
MENUITEM "About",IDM_ABOUT
}


MyDialog DIALOG 10, 10, 205, 60
STYLE 0x0004 | DS_CENTER | WS_CAPTION | WS_MINIMIZEBOX |
WS_SYSMENU | WS_VISIBLE | WS_OVERLAPPED | DS_MODALFRAME | DS_3DLOOK
CAPTION "Our Second Dialog Box"
BEGIN
LTEXT "Hi Rou", IDC_ROU1,  15,2,111,13
CONTROL "still fighting with the rc file?", IDC_ROU2, "Static", ES_LEFT, 15,16,111,13
CONTROL "Ciao bello", IDC_EDIT, "EDIT", ES_AUTOHSCROLL|ES_LEFT, 15,27,111,13
DEFPUSHBUTTON   "Say Hello", IDC_BUTTON,    141,10,52,13
PUSHBUTTON      "E&xit", IDC_EXIT,  141,26,52,13
END

Tedd

Stop making it complicated :P

MyDialog DIALOG 10, 10, 205, 60
STYLE 0x0004 | DS_CENTER | WS_CAPTION | WS_MINIMIZEBOX |
WS_SYSMENU | WS_VISIBLE | WS_OVERLAPPED | DS_MODALFRAME | DS_3DLOOK
CAPTION "Our Second Dialog Box"
BEGIN
    LTEXT "Some text above the edit box...",10001,10,5,120,10    // <------ left-aligned text (see also: CTEXT, RTEXT)
    EDITTEXT         IDC_EDIT,   15,17,111,13, ES_AUTOHSCROLL | ES_LEFT
    DEFPUSHBUTTON   "Say Hello", IDC_BUTTON,    141,10,52,13
    PUSHBUTTON      "E&xit", IDC_EXIT,  141,26,52,13
END
No snowflake in an avalanche feels responsible.

RuiLoureiro

Thank you jj2007

Quote from: Tedd on July 23, 2008, 08:45:01 PM
Stop making it complicated
Hi Tedd,
                It is just what i want. Thank you !


    LTEXT "Some text above the edit box...",10001,10,5,120,10   

Rui

jj2007

Quote from: Tedd on July 23, 2008, 08:45:01 PM
Stop making it complicated :P

Tedd, any idea why EDITTEXT "Ciao", IDC... does not work? My Gfa example above is 16-bit, but I doubt that MFC developers decided to deliberately drop this feature...

Tedd

Quote from: jj2007 on July 23, 2008, 09:50:45 PM
Tedd, any idea why EDITTEXT "Ciao", IDC... does not work? My Gfa example above is 16-bit, but I doubt that MFC developers decided to deliberately drop this feature...
The format for EDITTEXT is:
        EDITTEXT <ID>, <x>, <y>, <width>, <height> [, <style> [, <ex-style> ] ]

If the documentation says there's a <text> element in there, it's because of a lazy copy-paste mistake
-- since the standard format for most controls follows
        <CONTROL> <text>, <ID>, <x>, <y>, <width>, <height> [, <style> [, <ex-style> ] ]

If you don't do what resource compiler expects, it will complain - the documentation should say what it actually does :bdg
No snowflake in an avalanche feels responsible.

hutch--

I save myself the extra redudant typeing, I use only numbers for resources.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

jj2007

Quote from: Tedd on July 24, 2008, 10:34:04 AM
        EDITTEXT <ID>, <x>, <y>, <width>, <height> [, <style> [, <ex-style> ] ]

If the documentation says there's a <text> element in there, it's because of a lazy copy-paste mistake
-- since the standard format for most controls follows
        <CONTROL> <text>, <ID>, <x>, <y>, <width>, <height> [, <style> [, <ex-style> ] ]

DEFPUSHBUTTON text, ID...
PUSHBUTTON text, id,
LTEXT  text, ID...
CTEXT text, ID...
RTEXT text, ID...
STATE3 text, id, ...
RADIOBUTTON text, id,
GROUPBOX text, id,
CHECKBOX text, id,

So much to standard formats. I understand that combo and listbox don't allow to specify a text, but why EDITTEXT?? And, as I wrote earlier (but you might have been too busy to read that), it worked under 16-bit Windows.

PBrennick

JJ,
Stop grinding the wheel to no purpose. It is what it is. The CONTROL syntax works for every ... well. Control.  :bg

Switch to that method and forget it. Most of us have. Better yet, do it all in the assembly file using CreateWindowEX and forget the resource thing.

I am attaching a helper program for extracting source code from the Code Librarian in the GeneSys area.. Notice that it has a menu, label and listbox - all done in the assembly file.

-- Paul
The GeneSys Project is available from:
The Repository or My crappy website