TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Will Morgan
from: Jeffrey Habets
date: 1996-09-26 21:14:00
subject: More Dialog Help

Hallo Will!

22 September 1996 00:39, schreef Will Morgan aan All:

 WM> Can anyone tell me if there is an OS/2 Presentation Manager C/C++
 WM> equivalent of the following Windows MFC / Windows API snippet of code?
 WM> What I want to do is define an "empty" icon on an OS/2
P.M. dialog box,
 WM> then depending on the menu item / toolbar button that the user chooses,
 WM> send a certain ICON to the dialog box. I would send different icons,
 WM> depending on the menu item the user picked. In my MFC code, it goes
 WM> something like this...

 WM> // MFC Code

 WM> LPCSTR IdIconResource;
 WM> HICON hicon, hiconOld;
 WM> HINSTANCE TestInstance;

 WM> TestInstance = AfxGetInstanceHandle();

 WM> IdIconResource  = MAKEINTRESOURCE(IDR_ICON);
 WM> hicon = LoadIcon(TestInstance,IdIconResource);
 WM> hiconOld = (HICON)SendDlgItemMessage(IDR_NEWICON, STM_SETICON,
 WM>                                      (WPARAM)hicon, 0);


Here's some (untested) example code that should work:
// assuming that your icon resource is in the programs .exe

 HPOINTER  hptr;        // Pointer handle.
 HWND      hwndDlg;     // Dialog window handle

 hptr = WinLoadPointer(HWND_DESKTOP, (HMODULE)0, ID_ICON1);
 WinSendDlgItemMsg(hwndDlg, ID_ICON, WM_SETICON, MPFROMLONG(hptr), 0);

// A possible resource definition of the dialog could be for example:

ICON   ID_ICON  icon.ico
ICON   ID_ICON1 icon1.ico

DLGTEMPLATE 256 850 MOVEABLE DISCARDABLE
BEGIN
    DIALOG "Dialog Title", 256, 123, 101, 200, 91, FS_NOBYTEALIGN |
                FS_DLGBORDER | WS_CLIPSIBLINGS | WS_SAVEBITS | WS_VISIBLE,
                FCF_TITLEBAR | FCF_SYSMENU
    BEGIN
        CONTROL ID_ICON,               ID_ICON, 87, 56, 21, 16, WC_STATIC,
                                            SS_ICON | WS_GROUP | WS_VISIBLE
    END
END

Hope this helps..

ÖÄÄ¿ ÒÄÄ¿ ÒÄÄ¿ ÒÄÄ¿ ÖÄÒÄ¿ ÖÄ¿   jhabets{at}pi.net
º Ä¿ ÇÄÂÙ ÇÄ   ÇÄ     º   ÖÄÙ
ÓÄÄÙ Ð Á  ÐÄÄÙ ÐÄÄÙ   Ð   ÓÄÄÙ, Jeffrey 

--- GoldED/2 2.50+ /\ FMail/2 1.02+
* Origin: Why Windows? Simply switch of your Turbo.. (2:284/312.3)
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: 284/312 3 5 283/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™.