| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Writing to Client. |
JF> I have been attempting to program under EMX/Gcc here
JF> and have compiled some code from a book that does
JF> create a PM Window. However I am wondering how to
JF> display Text in the Client window. I had thought that
WinDrawText() or GpiCharString(), during your WM_PAINT message.
Here's a small sample program. So that the text is re-cenetered when you
change the size of the Window, I have created a window with the
CS_SIZEREDRAW style. Normally, I don't use CS_SIZEREDRAW, since this
requires the whole client area to be redrawn (this would be slow if you
were dispalying a bitmap, for example).
// compiled: icc /Kb+ /SS /B"/pm:pm" small3.c
#define INCL_WIN
#define INCL_DOS
#include
#include
#define ID_WINDOW 1
MRESULT EXPENTRY MyWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
static char mesg[] = "I'm a message!";
RECTL rect;
HPS hps;
switch (msg) {
case WM_ERASEBACKGROUND:
/* Return TRUE to request PM to paint the window background in
* SYSCLR_WINDOW.
*/
return (MRESULT) (TRUE);
case WM_PAINT:
hps = WinBeginPaint(hwnd, 0, NULL);
WinQueryWindowRect(hwnd, &rect);
WinDrawText(hps, strlen(mesg), mesg, &rect, 0, 0,
DT_CENTER | DT_VCENTER | DT_TEXTATTRS);
WinEndPaint(hps);
break;
default:
return WinDefWindowProc(hwnd, msg, mp1, mp2);
}
return 0;
}
int main(void)
{
HAB hab;
HMQ hmq;
HWND hwndClient;
HWND hwndFrame;
ULONG flCreate;
QMSG qmsg;
if (!(hab = WinInitialize(0)))
return 1;
if (!(hmq = WinCreateMsgQueue(hab, 0)))
return 1;
if (!WinRegisterClass(hab, (PSZ) "MyWindow", (PFNWP) MyWindowProc,
CS_SIZEREDRAW, 0))
return 1;
flCreate = FCF_SHELLPOSITION | FCF_SIZEBORDER | FCF_TASKLIST |
FCF_SYSMENU | FCF_TITLEBAR;
hwndFrame = WinCreateStdWindow(HWND_DESKTOP, WS_VISIBLE, &flCreate,
"MyWindow", NULL, 0, 0, ID_WINDOW, &hwndClient);
if (!hwndFrame || !hwndClient)
return 1; /* couldn't create window for some
* reason. */
while (WinGetMsg(hab, &qmsg, 0L, 0, 0))
WinDispatchMsg(hab, &qmsg);
WinDestroyWindow(hwndFrame);
WinDestroyMsgQueue(hmq);
WinTerminate(hab);
return 0;
}
--- Maximus/2 3.00
* Origin: Sol 3 * Toronto * V.32 * (905)858-8488 (1:259/414)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 517 628 713/888 800/1 @PATH: 259/414 400 99 250/99 3615/50 396/1 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™.