TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Will Morgan
from: Gerard Gerritsen
date: 1996-08-23 22:32:12
subject: Dialog Help

Hello Will!

Friday August 23 1996, Will Morgan writes to All:

 WM> One major problem is, I don't have a working example of how to set
 WM> up a MODELESS dialog in an OS/2 PM program.

The code has been written in Virtual Pascal, and has been copied from an
existing project (PlayPM/2) look for it on Hobbes or FernWood, have been
slashing some bugs and want to do some optimisations before releasing 1.1.



IDM_Lookup   : if Not(LookUploaded) then
LookUpHwnd:=WinLoadDlg(HWND_DESKTOP,0, LookUpWindowProc, 0,LookUpWindow2, NIL)
              else
            WinSetFocus(HWND_DESKTOP,LookUpHwnd);

-HWND_DESKTOP will be the parent
-Nil is the owner
-LookUpWindowProc is the message handler
-nil is the module where the dialog resource is located ( for normal .exe
it is 0, except if you put your resources into a dll )
-LookUpWindow2 is the index into the dialog file

My message handler for the dialog, cut out some dead wood (LookupWindowProc) is

Function  LookUpWindowProc(Window:Hwnd;Msg:Ulong;Mp1,Mp2:Mparam):Mresult;
  CONST
        Index:Cardinal=1;
        PreviousIndex:Cardinal=1;
        Teller:Byte=0;        {max 99 tracks }
        Htrack:Hwnd=0;

  BEGIN
    CASE MSG OF
 WM_CONTROL:begin
    If Short2FromMp(Mp1)=LN_SELECT then
     begin
    
Index:=succ(WinSendMsg(WinWindowFromId(Window,TrackBox2),LM_QuerySelection
, 0,0));  //find current selected text
                 If PreviousIndexIndex then
                   begin
                    PreviousIndex:=Index;
                    WinSetWindowText(HTrack,LAbels[Index]);
                   end;
                  end
                 end;

      WM_CLOSE,WM_COMMAND : BEGIN
                   LookUpLoaded:=false;
                   END;

      WM_INITDLG : begin
                    LookUpLoaded:=true;
                    HTrack:=WinWindowFromId(Window,TrackNumber2);
                    WinSetWindowText(HTrack,LAbels[PreviousIndex]);
                  end;
           END;
    Result := WinDefDlgProc(Window, MSG, Mp1, Mp2);
END;

And now for a small piece of the .dlg

#include 
DLGTEMPLATE TrackWindow2 LOADONCALL MOVEABLE DISCARDABLE
BEGIN
    DIALOG  "LookUp", TrackWindow2, 24, 69, 312, 31, WS_VISIBLE,
FCF_SYSMENU |
            FCF_TITLEBAR
    BEGIN
        LISTBOX         TrackBox2, 34, 2, 242, 29
        LTEXT           "Track", 1001, 1, 17, 29, 8
        CTEXT           "1", Track2, 5, 7, 20, 8, DT_VCENTER
        DEFPUSHBUTTON   "#8", 207, 282, 5, 26, 20, BS_ICON | BS_AUTOSIZE
    END
END

If you need more


==> Gerard/2   - member of team os/2 - gerritse{at}bos.nl

--- Fmail/2 1.02 Registered
* Origin: Author of PlayPM/2 -> 1.1 will be released (2:283/203.18)
SEEN-BY: 50/99 270/101 620/243 625/100 711/401 409 410 413 430 808 809 934
SEEN-BY: 711/955 712/407 515 624 628 713/888 800/1
@PATH: 283/203 2 512 280/801 270/101 712/515 711/808 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.