| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Re: Notebook Object |
Hi Richie!
RM> I'm new to programming for OS/2 so naturally I have a question. :)
:)
RM> When using the dialog editor, how does one implement the notebook
RM> object? That is, in order to have multiple pages. A snippet of code
RM> for 2 or 3 pages ( small ones ) would be most helpful. Thanks.
I hope, this will help you:
Notebook.c
--------------------------------------------------------------------------
#define INCL_WIN
#define INCL_DOS
#include
#include "Notebook.h"
MRESULT EXPENTRY Page1Function( HWND hwndDlg, ULONG msg, MPARAM mp1,
MPARAM mp2 );
MRESULT EXPENTRY Page2Function( HWND hwndDlg, ULONG msg, MPARAM mp1,
MPARAM mp2 );
MRESULT EXPENTRY NotebookDialogfunction( HWND hwndDlg, ULONG msg, MPARAM
mp1, MPARAM mp2 );
HAB hab;
INT main (VOID)
{
HMQ hmq;
QMSG qmsg;
HWND hwnddlg;
hab = WinInitialize(0);
hmq = WinCreateMsgQueue(hab, 0);
hwnddlg = WinLoadDlg(HWND_DESKTOP,
HWND_DESKTOP,
(PFNWP)NotebookDialogfunction,
NULLHANDLE,
DLG_NOTEBOOK,
NULL);
WinProcessDlg(hwnddlg);
WinDestroyWindow(hwnddlg);
WinDestroyMsgQueue(hmq);
WinTerminate(hab);
}
MRESULT EXPENTRY NotebookDialogfunction( HWND hwndDlg, ULONG msg, MPARAM
mp1, MPARAM mp2 )
{
HWND hwndNotebook, hwndPage1, hwndPage2;
ULONG idPage1, idPage2;
hwndNotebook = WinWindowFromID(hwndDlg, DLG_NBELEMENT);
switch ( msg )
{
case WM_INITDLG:
{
WinSendMsg(hwndNotebook, BKM_SETDIMENSIONS,
MPFROM2SHORT(150, 25),
MPFROMSHORT(BKA_MAJORTAB));
/* Nice colours - you don't really need them! */
WinSendMsg( hwndNotebook, BKM_SETNOTEBOOKCOLORS,
MPFROMLONG( CLR_PALEGRAY ),
MPFROMSHORT (BKA_BACKGROUNDMAJORCOLORINDEX));
WinSendMsg( hwndNotebook, BKM_SETNOTEBOOKCOLORS,
MPFROMLONG( CLR_PALEGRAY ),
MPFROMSHORT (BKA_BACKGROUNDPAGECOLORINDEX));
/* Get Page-IDs */
idPage1 = (ULONG)WinSendMsg(hwndNotebook, BKM_INSERTPAGE,
0L, MPFROM2SHORT(BKA_MAJOR | BKA_AUTOPAGESIZE, BKA_LAST));
WinSendMsg(hwndNotebook, BKM_SETTABTEXT,
MPFROMLONG(idPage1),
MPFROMP("Page 1"));
idPage2 = (ULONG)WinSendMsg(hwndNotebook, BKM_INSERTPAGE,
0L, MPFROM2SHORT(BKA_MAJOR | BKA_AUTOPAGESIZE, BKA_LAST));
WinSendMsg(hwndNotebook, BKM_SETTABTEXT,
MPFROMLONG(idPage2),
MPFROMP("Page 2"));
/* Load Dialogs */
hwndPage1 = WinLoadDlg(hwndDlg,
hwndDlg,
(PFNWP)Page1Function,
NULLHANDLE,
DLG_PAGE1,
NULL);
hwndPage2 = WinLoadDlg(hwndDlg,
hwndDlg,
(PFNWP)Page2Function,
NULLHANDLE,
DLG_PAGE2,
NULL);
/* Connect Dialogs with pages */
WinSendMsg(hwndNotebook, BKM_SETPAGEWINDOWHWND,
MPFROMLONG(idPage1),
MPFROMHWND(hwndPage1));
WinSendMsg(hwndNotebook, BKM_SETPAGEWINDOWHWND,
MPFROMLONG(idPage2),
MPFROMHWND(hwndPage2));
}
return (MRESULT)FALSE;
}
return WinDefDlgProc( hwndDlg, msg, mp1, mp2 );}
MRESULT EXPENTRY Page1Function( HWND hwndDlg, ULONG msg, MPARAM mp1,
MPARAM mp2 )
{
switch ( msg )
{
case WM_COMMAND:
{
if (SHORT1FROMMP(mp1)==CM_HELP) DosBeep(220, 100);
break;
}
default:
return WinDefDlgProc( hwndDlg, msg, mp1, mp2 );
}
return (MRESULT) FALSE;
}
MRESULT EXPENTRY Page2Function( HWND hwndDlg, ULONG msg, MPARAM mp1,
MPARAM mp2 )
{
switch ( msg )
{
case WM_COMMAND:
{
if (SHORT1FROMMP(mp1)==CM_HELP) DosBeep(220, 1000);
break;
}
default:
return WinDefDlgProc( hwndDlg, msg, mp1, mp2 );
}
return (MRESULT) FALSE;
}
----------------------------------------------------------------------
Notebook.rc
______________________________________________________________________
#include "Notebook.h"
#include "os2.h"
DLGTEMPLATE DLG_NOTEBOOK LOADONCALL MOVEABLE DISCARDABLE
BEGIN
DIALOG "Options", DLG_NOTEBOOK, -40, 20, 270, 150,
WS_VISIBLE | WS_CLIPCHILDREN, FCF_SYSMENU | FCF_DLGBORDER | FCF_TITLEBAR |
FCF_NOMOVEWITHOWNER
BEGIN
CONTROL "", DLG_NBELEMENT, 0, 0, 270, 150,
WC_NOTEBOOK, BKS_BACKPAGESBR | BKS_MAJORTABRIGHT |
BKS_SQUARETABS | BKS_TABTEXTCENTER | WS_GROUP |
WS_VISIBLE | BKS_SPIRALBIND
END
END
DLGTEMPLATE DLG_PAGE1 LOADONCALL MOVEABLE DISCARDABLE
BEGIN
DIALOG "", DLG_PAGE1, 0, 0, 140, 80, NOT FS_DLGBORDER | WS_VISIBLE
BEGIN
DEFPUSHBUTTON "~Help", CM_HELP, 50, 5, 40, 14
END
END
DLGTEMPLATE DLG_PAGE2 LOADONCALL MOVEABLE DISCARDABLE
BEGIN
DIALOG "", DLG_PAGE2, 0, 0, 140, 80, NOT FS_DLGBORDER | WS_VISIBLE
BEGIN
DEFPUSHBUTTON "~Help", CM_HELP, 50, 5, 40, 14
END
END
--------------------------------------------------------------------------
Notebook.h
--------------------------------------------------------------------------
INT main (VOID);
#define DLG_PAGE1 1100
#define DLG_PAGE2 1101
#define ID_MAIN 1000
#define CM_HELP 402
#define DLG_NOTEBOOK 4100
#define DLG_NBELEMENT 4101
--------------------------------------------------------------------------
That's it! :)
CU,
Ben
--- CrossPoint v3.1 R
* Origin: Arma virumque cano, Troiae qui primus ab oris... (2:2480/340.1)SEEN-BY: 50/99 54/99 270/101 620/243 625/160 711/401 413 430 934 712/311 407 SEEN-BY: 712/505 506 517 623 624 704 713/317 800/1 @PATH: 2480/340 92 3500 24/777 888 396/1 270/101 712/624 711/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™.