VOID ClientPaint(HWND hwnd) { POINTL pt; HPS hps; RECTL rcl; LONG lLen; LONG lCenter; WinInvalidateRect(hwnd,(PRECTL)NULL,FALSE); hps = WinBeginPaint(hwnd,(HPS)NULL,&rcl ); // if (bShowingProgress) // rcl.yBottom = 60L; WinFillRect(hps,&rcl,CLR_WHITE); lCenter = (INITWIDTH / 2); if (bDebug) { GpiSetBackColor(hps,CLR_WHITE); GpiSetBackMix(hps,BM_OVERPAINT); GpiCreateLogFont(hps,NULL,3,&fattMsgFont); GpiSetColor(hps,CLR_BLACK); GpiSetCharSet(hps,3); pt.x = 10; if (szDebugLineOne[0] != 0) { pt.y = 82L; GpiCharStringAt(hps,&pt,strlen(szDebugLineOne),szDebugLineOne); } if (szDebugLineTwo[0] != 0) { pt.y = 62L; GpiCharStringAt(hps,&pt,strlen(szDebugLineTwo),szDebugLineTwo); } } else { GpiSetColor(hps,CLR_CYAN); GpiSetBackColor(hps,CLR_WHITE); GpiSetBackMix(hps,BM_OVERPAINT); GpiCreateLogFont(hps, NULL, 2, &fattBigFont); GpiSetCharSet(hps,2); pt.x = (lCenter - (10 * stBigCell.cx)); pt.y = 60L; GpiCharStringAt(hps,&pt,21,"OS/tools Installation"); } if (!bShowingProgress) PrintBanners(szBannerOne,szBannerTwo); WinEndPaint(hps); }
/************************************************************************** * * Name : InitClientArea() * * Description: Prepares the client area to accept the images * * Concepts : Called once by the Init() routine * - obtain a window device context * - define the image presentation space * - associate the two * - set foreground/background colours & * background mix for the presentation space * * API's : WinOpenWindowDC * GpiCreatePS * GpiSetColor * GpiSetBackColor * GpiSetBackMix * * Parameters : hwnd = client window handle * * Return : TRUE - client area successfully set up * FALSE - client area setup failed * *************************************************************************/ BOOL InitClientArea(HWND hwnd) { SIZEL sizl; sizl.cx = 0L; /* set size to default for device */ sizl.cy = 0L; /* (full screen) */ vhdc = WinOpenWindowDC(hwnd); if (!vhdc) return FALSE; vhps = GpiCreatePS(vhab, vhdc, &sizl, (ULONG)PU_PELS | GPIT_NORMAL | GPIA_ASSOC ); if (!vhps) return FALSE; GpiSetColor(vhps, vlForeClr); GpiSetBackColor(vhps, vlBackClr); GpiSetBackMix(vhps, BM_OVERPAINT); return TRUE; } /* End of InitClientArea */
int icqskin_drawImage(HPS hps, PRECTL rcl, HBITMAP image, HBITMAP mask) { POINTL aptl[4]; BITMAPINFOHEADER bmpData; int x,y; GpiQueryBitmapParameters(image, &bmpData); x = ((rcl->xRight - rcl->xLeft)/2) - (bmpData.cx/2); y = ((rcl->yTop - rcl->yBottom)/2) - (bmpData.cy/2); aptl[0].x = x+rcl->xLeft; aptl[0].y = y+rcl->yBottom; aptl[1].x = (aptl[0].x+bmpData.cx)-1; aptl[1].y = (aptl[0].y+bmpData.cy)-1; aptl[2].x = aptl[2].y = 0; aptl[3].x = bmpData.cx; aptl[3].y = bmpData.cy; GpiSetColor(hps,CLR_WHITE); GpiSetBackColor(hps,CLR_BLACK); GpiWCBitBlt( hps, mask, 4, aptl, ROP_SRCAND, BBO_IGNORE); GpiWCBitBlt( hps, image, 4, aptl, ROP_SRCPAINT, BBO_IGNORE); return bmpData.cy; }
void Paint(void) { HPS hps; RECTL rcl; hps = WinBeginPaint(hwndClient,(HPS)0,(PRECTL)&rcl); GpiSetColor(hps,CLR_WHITE); GpiSetBackColor(hps,CLR_BLUE); GpiSetBackMix(hps,BM_OVERPAINT); WinFillRect(hps,&rcl,CLR_WHITE); WinEndPaint(hps); }
void ClearScreen(void) { HPS hps; RECTL rcl; WinInvalidateRect(hwndClient,(PRECTL)NULL,FALSE); hps = WinBeginPaint(hwndClient,(HPS)0,(PRECTL)&rcl); GpiSetColor(hps,CLR_WHITE); GpiSetBackColor(hps,CLR_BLUE); GpiSetBackMix(hps,BM_OVERPAINT); WinFillRect(hps,&rcl,CLR_WHITE); WinEndPaint(hps); }
void drawTransparent(HPS hps, PPOINTL p, XBITMAP *b) { BITMAPINFOHEADER bmpData; POINTL aptl[4]; if(!b->masc) return; bmpData.cbFix = sizeof(bmpData); GpiQueryBitmapParameters(b->masc, &bmpData); GpiSetColor(hps,CLR_WHITE); GpiSetBackColor(hps,CLR_BLACK); // Target - Inclusive aptl[0].x = p->x; aptl[0].y = p->y; aptl[1].x = p->x+bmpData.cx; aptl[1].y = p->y+bmpData.cy; // Source - Non inclusive aptl[2].x = 0; aptl[2].y = 0; aptl[3].x = bmpData.cx+1; aptl[3].y = bmpData.cy+1; GpiWCBitBlt( hps, b->masc, 4, aptl, ROP_SRCAND, BBO_IGNORE); GpiWCBitBlt( hps, b->image, 4, aptl, ROP_SRCPAINT, BBO_IGNORE); /* GpiWCBitBlt( hps, b->image, 4, aptl, ROP_SRCCOPY, BBO_IGNORE); */ }
static void LboxDrawLine(HWND hwnd, OWNERITEM *item, RECTL *rcl, image_contents_screencode_t *line) { const HPS hps = item->hps; const int name = WinDlgLboxSelectedItem(hwnd, DID_FONTNAME_LB); FATTRS font = { sizeof(FATTRS), 0, 0, "", 0, 0, 8, 8, 0, 0 }; strcpy(font.szFacename, fnames[name]); GpiCreateLogFont(hps, NULL, 1, &font); GpiSetCharSet(hps, 1); GpiSetBackColor(hps, item->fsState ? CLR_DARKGRAY : CLR_WHITE); GpiSetColor(hps, item->fsState ? CLR_WHITE : CLR_DEFAULT); GpiCharStringPosAt(hps, (POINTL*)rcl, rcl, CHS_OPAQUE, line->length, line->line, NULL); GpiSetCharSet(hps, 0); GpiDeleteSetId(hps, 1); }
USHORT drawIcon(HPS hps, XBITMAP *b, USHORT id, USHORT x, USHORT y) { BITMAPINFOHEADER bmpData; POINTL aptl[4]; USHORT fator; if(!b->masc) return 0; bmpData.cbFix = sizeof(bmpData); GpiQueryBitmapParameters(b->masc, &bmpData); aptl[0].x = x; aptl[0].y = y; aptl[1].x = x+bmpData.cy-1; aptl[1].y = y+bmpData.cy-1; fator = bmpData.cy * id; aptl[2].x = fator; aptl[2].y = 0; aptl[3].x = fator + bmpData.cy; aptl[3].y = bmpData.cy; GpiSetColor(hps,CLR_WHITE); GpiSetBackColor(hps,CLR_BLACK); GpiWCBitBlt( hps, b->masc, 4, aptl, ROP_SRCAND, BBO_IGNORE); GpiWCBitBlt( hps, b->image, 4, aptl, ROP_SRCPAINT, BBO_IGNORE); return bmpData.cy; }
void icqskin_drawSelected(HWND hwnd, HPS hps, PRECTL rcl, HBITMAP img, HBITMAP msk) { BITMAPINFOHEADER bmpData; USHORT cx = rcl->xRight - rcl->xLeft; int sz; int f; if(img == NO_IMAGE) { WinFillRect(hps, rcl, ICQCLR_SELECTEDBG); return; } GpiQueryBitmapParameters(img, &bmpData); GpiSetColor(hps,CLR_WHITE); GpiSetBackColor(hps,CLR_BLACK); if(cx > bmpData.cx) { sz = bmpData.cx / 3; for(f=rcl->xLeft+sz;f<(rcl->xRight-(sz*2));f+=sz) drawTransparent(hps, img, msk, f, rcl->yBottom, sz, bmpData.cy, sz, 0); drawTransparent(hps, img, msk, rcl->xRight-(sz*2), rcl->yBottom, sz, bmpData.cy, sz, 0); drawTransparent(hps, img, msk, rcl->xLeft, rcl->yBottom, sz, bmpData.cy, 0, 0); drawTransparent(hps, img, msk, rcl->xRight-sz, rcl->yBottom, sz, bmpData.cy, bmpData.cx-sz, 0); } else { sz = cx / 2; drawTransparent(hps, img, msk, rcl->xRight-sz, rcl->yBottom, sz, bmpData.cy, bmpData.cx-sz, 0); drawTransparent(hps, img, msk, rcl->xLeft, rcl->yBottom, sz, bmpData.cy, 0, 0); } }
USHORT icqskin_drawIcon(SKINDATA *s, HPS hps, USHORT id, USHORT x, USHORT y) { POINTL aptl[4]; USHORT fator; aptl[0].x = x; aptl[0].y = y; aptl[1].x = x+s->iconSize-1; aptl[1].y = y+s->iconSize-1; fator = s->iconSize * id; aptl[2].x = fator; aptl[2].y = 0; aptl[3].x = fator + s->iconSize; aptl[3].y = s->iconSize; GpiSetColor(hps,CLR_WHITE); GpiSetBackColor(hps,CLR_BLACK); GpiWCBitBlt( hps,s->iconMasc,4,aptl,ROP_SRCAND,BBO_IGNORE); GpiWCBitBlt( hps,s->iconImage,4,aptl,ROP_SRCPAINT,BBO_IGNORE); return s->iconSize; }
VOID MainPaint(HWND hwnd) { RECTL rclUpdate; RECTL rclWnd; RECTL rclDraw; HPS hps; POINTL pt; LONG LineHeight; LONG Descender; PCHAR pText; LONG ptTextStart; static LONG Inc[] = { 10, 10, 10, 12, 12, 12, 14, 14, 14, 16, 16, 16, 18, 18, 18, 20, 20, 20, 22, 22, 22, 24, 24, 24 }; //BIDI static PCHAR TextLines[] = { "~DrawText", //0 "CharString", //1 "CharStringAt", //2 "CharStringPos", //3 "CharStringPosAt", //4 "DrawText(QueryRect)", //5 "QueryCharStringPos", //6 "QueryCharStringPosAt", //7 "QueryTextBox" //8 }; static PCHAR TextLines_API[] = { "WinDrawText:", //0 "GpiCharString:", //1 "GpiCharStringAt:", //2 "GpiCharStringPos:", //3 "GpiCharStringPosAt:", //4 "WinDrawText(QueryRect):", //5 "GpiQueryCharStringPos:", //6 "GpiQueryCharStringPosAt:", //7 "GpiQueryTextBox:", //8 "Current Clipboard TextBuffer:" //9 }; ULONG GpiBidiAttr; ULONG NullBidiAttr = 0L; hps = WinBeginPaint(hwnd, NULLHANDLE, (PRECTL)&rclUpdate); // Get the bidi attribute of the presentation space, so that // we can flip/flip between a NULL bidiattribute and this one // GpiBidiAttr = GpiQueryBidiAttr(hps); /* fill update rectangle with window color */ WinFillRect(hps, (PRECTL)&rclUpdate, SYSCLR_PAGEBACKGROUND ); CalcLineHeight(hps, &LineHeight, &Descender); GpiSetColor ( hps, CLR_BLUE ) ; GpiSetBackColor( hps, CLR_RED ) ; WinQueryWindowRect(hwnd, (PRECTL)&rclWnd); ptTextStart = rclWnd.xRight * 2/5 ; // ------------------------------------- // WinDrawText! // ------------------------------------- pt.x = 0; pt.y = rclWnd.yTop - LineHeight + Descender; rclDraw.xLeft = rclWnd.xLeft; rclDraw.xRight = rclWnd.xRight; rclDraw.yBottom = pt.y - Descender; rclDraw.yTop = rclDraw.yBottom + LineHeight ; GpiSetBidiAttr(hps, NullBidiAttr); pText = TextLines_API[0]; WinDrawText ( hps, strlen(pText), pText, &rclDraw, 0L, 0L, DT_LEFT | DT_ERASERECT | DT_TEXTATTRS | DT_MNEMONIC ); rclDraw.xLeft = ptTextStart; GpiSetBidiAttr(hps, GpiBidiAttr); pText = TextLines[0]; WinDrawText ( hps, strlen(pText), pText, &rclDraw, 0L, 0L, DT_LEFT | DT_ERASERECT | DT_TEXTATTRS | DT_MNEMONIC ); // ------------------------------------- // GpiCharString // ------------------------------------- pt.y -= LineHeight; pt.x = 0; GpiSetCurrentPosition( hps, &pt ) ; pText = TextLines_API[1]; GpiSetBidiAttr(hps, NullBidiAttr); GpiCharString(hps, strlen(pText), pText); pt.x = ptTextStart; GpiSetCurrentPosition( hps, &pt ) ; pText = TextLines[1]; GpiSetBidiAttr(hps, GpiBidiAttr); GpiCharString(hps, strlen(pText), pText); // ------------------------------------- // GpiCharStringAt // ------------------------------------- pt.y -= LineHeight ; pt.x = 0; pText = TextLines_API[2]; GpiSetBidiAttr(hps, NullBidiAttr); GpiCharStringAt(hps, &pt, strlen(pText), pText); pt.x = ptTextStart; pText = TextLines[2]; GpiSetBidiAttr(hps, GpiBidiAttr); GpiCharStringAt(hps, &pt, strlen(pText), pText); // ------------------------------------- // GpiCharStringPos // ------------------------------------- pt.y -= LineHeight ; pt.x = 0; GpiSetCurrentPosition( hps, &pt ) ; rclDraw.xLeft = rclWnd.xLeft; rclDraw.xRight = ptTextStart - 4; rclDraw.yBottom = pt.y - Descender; rclDraw.yTop = rclDraw.yBottom + LineHeight ; pText = TextLines_API[3]; GpiSetBidiAttr(hps, NullBidiAttr); GpiCharStringPos(hps, &rclDraw, CHS_VECTOR | CHS_OPAQUE, strlen(pText), pText, &Inc[0] ); rclDraw.xLeft = ptTextStart; rclDraw.xRight = rclWnd.xRight; rclDraw.yBottom = pt.y - Descender ; rclDraw.yTop = rclDraw.yBottom + LineHeight ; pt.x = ptTextStart; GpiSetCurrentPosition( hps, &pt ) ; pText = TextLines[3]; GpiSetBidiAttr(hps, GpiBidiAttr); GpiCharStringPos(hps, &rclDraw, CHS_VECTOR | CHS_OPAQUE, strlen(pText), pText, &Inc[0]); // ------------------------------------- // GpiCharStringPosAt // ------------------------------------- pt.y -= LineHeight ; pt.x = 0; rclDraw.xLeft = rclWnd.xLeft; rclDraw.xRight = ptTextStart - 4; rclDraw.yBottom = pt.y - Descender ; rclDraw.yTop = rclDraw.yBottom + LineHeight ; pText = TextLines_API[4]; GpiSetBidiAttr(hps, NullBidiAttr); GpiCharStringPosAt(hps, &pt, &rclDraw, CHS_VECTOR | CHS_OPAQUE, strlen(pText), pText, &Inc[0] ); rclDraw.xLeft = ptTextStart; rclDraw.xRight = rclWnd.xRight; rclDraw.yBottom = pt.y - Descender ; rclDraw.yTop = rclDraw.yBottom + LineHeight ; pt.x = ptTextStart; pText = TextLines[4]; GpiSetBidiAttr(hps, GpiBidiAttr); GpiCharStringPosAt(hps, &pt, &rclDraw, CHS_VECTOR | CHS_OPAQUE, strlen(pText), pText, &Inc[0]); // ------------------------------------- // Current Clipboard TextBuffer // // This is used as a means of "looking inside" the // clipbaord. (This is a clipboard viewer for the poor...) // This part shows the text in szPasteText. // To operate: // - Copy/Cut text from anywhere to the clipbaord. // - select: Edit --> Paste --> No Conversion // - The clipboard text will be shown (UNMODIFIED BUFFER) // in our window. // ------------------------------------- pt.y -= LineHeight ; pt.x = 0; pText = TextLines_API[9]; GpiSetBidiAttr(hps, NullBidiAttr); GpiCharStringAt(hps, &pt, strlen(pText), pText); pt.x = ptTextStart; pText = szPasteText; GpiCharStringAt(hps, &pt, strlen(pText), pText); //BIDI- end /* * Add painting routines here. Hps is now the HPS for * the window and rclUpdate contains the update rectangle. */ WinEndPaint(hps); } /* MainPaint() */
void loadTransparent( HAB hab, HDC hdc, HPS hps, XBITMAP *x, PSZ FileName) { BITMAPINFOHEADER2 bmih; HBITMAP base = LoadBitmap(hab,hdc,hps,FileName); BITMAPINFOHEADER pbmpData; /* bit-map information header */ POINTL aptlPoints[4]; // DBGMessage(FileName); if(x->masc) GpiDeleteBitmap(x->masc); if(x->image) GpiDeleteBitmap(x->image); memset(x,0,sizeof(XBITMAP)); GpiQueryBitmapParameters(base, &pbmpData); memset(&bmih,0, sizeof(BITMAPINFOHEADER2)); bmih.cbFix = sizeof(bmih); bmih.cx = pbmpData.cx; bmih.cy = pbmpData.cy; bmih.cPlanes = 1; bmih.cBitCount = 1; x->masc = GpiCreateBitmap( hps, &bmih, 0L, NULL, NULL); GpiSetBitmap(hps,x->masc); aptlPoints[0].x=0; aptlPoints[0].y=0; aptlPoints[1].x=aptlPoints[0].x+pbmpData.cx-1; aptlPoints[1].y=aptlPoints[0].y+pbmpData.cy-1; aptlPoints[2].x=0; aptlPoints[2].y=0; aptlPoints[3].x=aptlPoints[2].x+pbmpData.cx; aptlPoints[3].y=aptlPoints[2].y+pbmpData.cy; GpiSetColor(hps,CLR_WHITE); GpiSetBackColor(hps,CLR_PINK); GpiWCBitBlt( hps, base, 4, aptlPoints, ROP_NOTSRCCOPY, BBO_IGNORE); bmih.cbFix = sizeof(bmih); bmih.cx = pbmpData.cx; bmih.cy = pbmpData.cy; bmih.cPlanes = 1; bmih.cBitCount = 24; x->image = GpiCreateBitmap( hps, &bmih, 0L, NULL, NULL); GpiSetBitmap(hps,x->image); GpiSetColor(hps,CLR_WHITE); GpiSetBackColor(hps,CLR_BLACK); GpiWCBitBlt( hps, x->masc, 4, aptlPoints, ROP_NOTSRCCOPY, BBO_IGNORE); GpiWCBitBlt( hps, base, 4, aptlPoints, ROP_SRCAND, BBO_IGNORE); GpiSetBitmap(hps,NULLHANDLE); GpiDeleteBitmap(base); }
/************************************************************************** * * Name : MyWindowProc * * Description: The window procedure associated with the client area in * the standard frame window. It processes all messages * either sent or posted to the client area, depending on * the message command and parameters. * * Concepts : * * API's : WinLoadString * WinInvalidateRegion * WinPostMsg * WinDefWindowProc * WinBeginPaint * GpiSetColor * GpiSetBackColor * GpiSetBackMix * GpiCharStringAt * WinEndPaint * * Parameters : hwnd = window handle * msg = message code * mp1 = first message parameter * mp2 = second message parameter * * Return : depends on message sent * *************************************************************************/ MRESULT EXPENTRY MyWindowProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) { switch( msg ) { case WM_TIMER: { WinInvalidateRegion( hwnd, 0L, FALSE ); break; } case WM_CREATE: /* * Window initialization is performed here in WM_CREATE processing * WinLoadString loads strings from the resource file. */ WinLoadString( hab, (HMODULE)0L, IDS_HELLO, STRINGLENGTH, szHello ); WinLoadString( hab, (HMODULE)0L, IDS_1, STRINGLENGTH, sz1 ); WinLoadString( hab, (HMODULE)0L, IDS_2, STRINGLENGTH, sz2 ); WinLoadString( hab, (HMODULE)0L, IDS_3, STRINGLENGTH, sz3 ); strcpy( szString, szHello ); /* Copy text Hello into szString*/ break; case WM_COMMAND: /* * When the user chooses option 1, 2, or 3 from the Options pull- * down, the text string is set to 1, 2, or 3, and * WinInvalidateRegion sends a WM_PAINT message. * When Exit is chosen, the application posts itself a WM_CLOSE * message. */ { USHORT command; /* WM_COMMAND command value */ command = SHORT1FROMMP(mp1); /* Extract the command value */ switch (command) { case ID_EXITPROG: WinPostMsg( hwnd, WM_CLOSE, (MPARAM)0, (MPARAM)0 ); break; default: return WinDefWindowProc( hwnd, msg, mp1, mp2 ); } break; } case WM_ERASEBACKGROUND: /* * Return TRUE to request PM to paint the window background * in SYSCLR_WINDOW. */ return (MRESULT)( TRUE ); case WM_PAINT: /* * Window contents are drawn here in WM_PAINT processing. */ { HPS hps; /* Presentation Space handle */ RECTL rc; /* Rectangle coordinates */ POINTL pt; /* String screen coordinates */ POINTL pPos; LONG lColor,r,g,b; FATTRS fat; HPS shps = WinGetScreenPS(HWND_DESKTOP); fat.usRecordLength = sizeof(FATTRS); /* sets size of structure */ fat.fsSelection = 0; /* uses default selection */ fat.lMatch = 0L; /* does not force match */ fat.idRegistry = 0; /* uses default registry */ fat.usCodePage = 0; /* code-page 850 */ fat.lMaxBaselineExt = 14L; /* requested font height is 12 pels */ fat.lAveCharWidth = 14L; /* requested font width is 12 pels */ fat.fsType = 0; /* uses default type */ fat.fsFontUse = FATTR_FONTUSE_NOMIX;/* doesn't mix with graphics */ strcpy(fat.szFacename ,"Courier"); WinQueryPointerPos(HWND_DESKTOP, &pPos); hps = WinBeginPaint( hwnd, 0L, &rc ); GpiCreateLogColorTable(shps, 0, LCOLF_RGB, 0, 0, NULL); GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, NULL); pt.x = 10; pt.y = 27; /* Set the text coordinates, */ lColor=GpiQueryPel(shps, &pPos); GpiSetBackColor( hps, 16777215); /* its background and */ WinFillRect( hps, &rc, lColor); GpiSetBackMix( hps, BM_OVERPAINT ); /* how it mixes, */ b = lColor & 0x000000FF; lColor = lColor >> 8; g = lColor & 0x000000FF; lColor = lColor >> 8; r = lColor & 0x000000FF; WinReleasePS(shps); sprintf(szString,"Color: #%.2X%.2X%.2X",r,g,b); GpiCreateLogFont(hps, NULL, 1L, &fat); GpiSetCharSet(hps, 1L); GpiSetCharMode(hps, CM_MODE1); GpiCharStringAt( hps,&pt ,(LONG)strlen( szString ), szString ); WinEndPaint( hps ); /* Drawing is complete */ break; } case WM_CLOSE: WinPostMsg( hwnd, WM_QUIT, (MPARAM)0,(MPARAM)0 );/* Cause termination*/ break; default: /* * Everything else comes here. This call MUST exist * in your window procedure. */ return WinDefWindowProc( hwnd, msg, mp1, mp2 ); } return (MRESULT)FALSE; } /* End of MyWindowProc */
HBITMAP icqskin_createBackground(HWND hwnd, HBITMAP base) { SIZEL sizl = { 0, 0 }; DEVOPENSTRUC dop = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L}; HAB hab = WinQueryAnchorBlock(hwnd); HBITMAP btm = NO_IMAGE; HWND owner = WinQueryWindow(hwnd, QW_OWNER); HPS hps; HDC hdc; SWP swp; BITMAPINFOHEADER2 bmih; BITMAPINFOHEADER bmpData; RECTL rcl; HBITMAP img; HBITMAP msk; HBITMAP bg; POINTL aptlPoints[4]; POINTL p; int f; int sz; WinQueryWindowPos(hwnd, &swp); hdc = DevOpenDC(hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE); hps = GpiCreatePS(hab, hdc, &sizl, PU_PELS | GPIT_MICRO | GPIA_ASSOC); /* Make base images */ GpiQueryBitmapParameters(base, &bmpData); memset(&bmih,0, sizeof(BITMAPINFOHEADER2)); bmih.cbFix = sizeof(bmih); bmih.cx = bmpData.cx; bmih.cy = bmpData.cy; bmih.cPlanes = 1; bmih.cBitCount = 1; msk = GpiCreateBitmap(hps, &bmih, 0L, NULL, NULL); GpiSetBitmap(hps,msk); aptlPoints[0].x=0; aptlPoints[0].y=0; aptlPoints[1].x=aptlPoints[0].x+bmpData.cx-1; aptlPoints[1].y=aptlPoints[0].y+bmpData.cy-1; aptlPoints[2].x=0; aptlPoints[2].y=0; aptlPoints[3].x=aptlPoints[2].x+bmpData.cx; aptlPoints[3].y=aptlPoints[2].y+bmpData.cy; GpiSetColor(hps,CLR_WHITE); GpiSetBackColor(hps,CLR_PINK); GpiWCBitBlt(hps,base,4,aptlPoints,ROP_NOTSRCCOPY,BBO_IGNORE); /* Create base image */ bmih.cbFix = sizeof(bmih); bmih.cx = bmpData.cx; bmih.cy = bmpData.cy; bmih.cPlanes = 1; bmih.cBitCount = 24; img = GpiCreateBitmap( hps, &bmih, 0L, NULL, NULL); GpiSetBitmap(hps,img); GpiSetColor(hps,CLR_WHITE); GpiSetBackColor(hps,CLR_BLACK); GpiWCBitBlt( hps,msk,4,aptlPoints,ROP_NOTSRCCOPY,BBO_IGNORE); GpiWCBitBlt( hps,base,4,aptlPoints,ROP_SRCAND,BBO_IGNORE); /* Draw background */ memset(&bmih,0, sizeof(BITMAPINFOHEADER2)); bmih.cbFix = sizeof(bmih); bmih.cx = swp.cx; bmih.cy = swp.cy; bmih.cPlanes = 1; bmih.cBitCount = 24; btm = GpiCreateBitmap(hps,&bmih,0L,NULL,NULL); GpiSetBitmap(hps, btm); // Ask owner window to draw the background icqskin_loadPallete(hps, 0, (const ULONG *) WinSendMsg(hwnd,WMICQ_QUERYPALLETE,0,0)); rcl.xLeft = rcl.yBottom = 0; rcl.xRight = swp.cx; rcl.yTop = swp.cy; bg = icqskin_queryBackground(owner); if(!bg || bg == NO_IMAGE) { WinFillRect(hps, &rcl, ICQCLR_BACKGROUND); } else { WinMapWindowPoints(hwnd, owner, (POINTL *) &rcl, 2); p.x = p.y = 0; WinDrawBitmap(hps, bg, &rcl, &p, CLR_WHITE, CLR_BLACK, DBM_NORMAL); } GpiSetColor(hps,CLR_WHITE); GpiSetBackColor(hps,CLR_BLACK); if(swp.cx > bmpData.cx) { sz = bmpData.cx / 3; for(f=sz;f<(swp.cx-(sz*2));f += sz) drawTransparent(hps, img, msk, f, 0, sz, bmpData.cy, sz, 0); drawTransparent(hps, img, msk, swp.cx-(sz*2), 0, sz, bmpData.cy, sz, 0); drawTransparent(hps, img, msk, 0, 0, sz, bmpData.cy, 0, 0); drawTransparent(hps, img, msk, swp.cx-sz, 0, sz, bmpData.cy, bmpData.cx-sz, 0); } else { sz = swp.cx / 2; drawTransparent(hps, img, msk, 0, 0, sz, bmpData.cy, 0, 0); drawTransparent(hps, img, msk, sz, 0, sz, bmpData.cy, bmpData.cx-sz, 0); } // Release resources GpiSetBitmap(hps, NULLHANDLE); GpiDeleteBitmap(img); GpiDeleteBitmap(msk); GpiDestroyPS(hps); DevCloseDC(hdc); return btm; }
MRESULT EXPENTRY XLogoWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { HPS hps; HWND hwndMenu; /* Menu resource */ RECTL rcl; /* For finding current window dimensions */ BOOL fSuccess; switch(msg) { case WM_ERASEBACKGROUND: /* * Return TRUE to request PM to paint the window background * in SYSCLR_WINDOW. */ return (MRESULT)( TRUE ); case WM_PAINT: /* * Window contents are drawn here in WM_PAINT processing. */ { HPS hps; /* Presentation Space handle */ RECTL rc; /* Rectangle coordinates */ POINTL pt; /* String screen coordinates */ LONG Lx, Ly; /* Starting points for paths A and B */ POINTL PathAStart, PathBStart; POINTL PathAPolygon[5], PathBPolygon[5]; /* Paths A, B definitions */ /* Create a presentation space */ hps = WinBeginPaint( hwnd, 0L, &rc ); GpiSetColor(hps, CLR_BLACK); /* colour of the text, */ GpiSetBackColor(hps, CLR_BACKGROUND); /* its background and */ GpiSetBackMix(hps, BM_OVERPAINT); /* how it mixes, */ /* and draw the string...*/ WinFillRect( hps, &rc, SYSCLR_WINDOW); WinQueryWindowRect(hwnd, &rcl); Lx = rcl.xRight - rcl.xLeft; /* Calculate window dimensions! */ Ly = rcl.yTop - rcl.yBottom; /* Find starting points of the two paths which make up the X */ PathAStart.x = 0.061 * Lx; PathAStart.y = Ly; PathBStart.x = 0.864 * Lx; PathBStart.y = Ly; /* Find the points for path A, the left half of the X */ PathAPolygon[0].x = 0.404 * Lx; PathAPolygon[0].y = 0.483 * Ly; PathAPolygon[1].x = 0.06 * Lx; PathAPolygon[1].y = 0; PathAPolygon[2].x = 0.141 * Lx; PathAPolygon[2].y = 0; PathAPolygon[3].x = 0.556 * Lx; PathAPolygon[3].y = 0.589 * Ly; PathAPolygon[4].x = 0.288 * Lx; PathAPolygon[4].y = Ly; /* Find the points for path B, the right half of the X */ PathBPolygon[0].x = 0.455 * Lx; PathBPolygon[0].y = 0.417 * Ly; PathBPolygon[1].x = 0.722 * Lx; PathBPolygon[1].y = 0; PathBPolygon[2].x = 0.939 * Lx; PathBPolygon[2].y = 0; PathBPolygon[3].x = 0.6 * Lx; PathBPolygon[3].y = 0.517 * Ly; PathBPolygon[4].x = 0.939 * Lx; PathBPolygon[4].y = Ly; /* Define and draw path A */ GpiBeginPath(hps, 1L); GpiMove(hps, &PathAStart); GpiPolyLine(hps, 5L, PathAPolygon); GpiCloseFigure(hps); GpiEndPath(hps); GpiFillPath(hps, 1L, FPATH_ALTERNATE); /* Define and draw path B. Path number must be 1L */ GpiBeginPath(hps, 1L); GpiMove(hps, &PathBStart); GpiPolyLine(hps, 5L, PathBPolygon); GpiCloseFigure(hps); GpiEndPath(hps); GpiFillPath(hps, 1L, FPATH_ALTERNATE); WinEndPaint(hps); break; } case WM_BUTTON2DOWN: { /* Opens the popup menu at current mouse co-ordinates */ hwndMenu = WinLoadMenu(hwnd, (HMODULE)NULL, ID_X); fSuccess = WinPopupMenu(hwnd, hwndFrame, hwndMenu, MOUSEMSG(&msg)->x, MOUSEMSG(&msg)->y, IDM_EXIT, PU_POSITIONONITEM | PU_HCONSTRAIN | PU_VCONSTRAIN | PU_MOUSEBUTTON2DOWN | PU_MOUSEBUTTON2); break; } case WM_CLOSE: /* * This is the place to put your termination routines */ WinPostMsg( hwnd, WM_QUIT, (MPARAM)0,(MPARAM)0 ); break; case WM_COMMAND: switch (SHORT1FROMMP (mp1)) { case IDM_ABOUT: /* Show Product information dialog box */ WinDlgBox(HWND_DESKTOP, hwnd, AboutDlgProc, 0, IDD_ABOUT, 0); return ((MRESULT)0); case IDM_EXIT: WinSendMsg (hwnd, WM_CLOSE, 0L, 0L); return ((MRESULT)0); } break; default: /* * Everything else comes here. This call MUST exist * in your window procedure. */ return WinDefWindowProc( hwnd, msg, mp1, mp2 ); } return (MRESULT)FALSE; } /* End of XLogoWndProc */
HBITMAP icqskin_createFrameBackground(HWND hwnd, HBITMAP bg, short cx, short cy, HBITMAP *img, HBITMAP *msk) { #ifndef SKINNED_GUI return NO_IMAGE; #else SIZEL sizl = { 0, 0 }; DEVOPENSTRUC dop = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L}; HAB hab = WinQueryAnchorBlock(hwnd); HPS hps; HDC hdc; BITMAPINFOHEADER bmpData; BITMAPINFOHEADER2 bmih; RECTL rcl; int x; int y; int f; icqskin_deleteImage(bg); for(f=0;f<ICQFRAME_SKINBITMAPS && img[f] == NO_IMAGE;f++); if(f >= ICQFRAME_SKINBITMAPS) return NO_IMAGE; hdc = DevOpenDC(hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE); hps = GpiCreatePS(hab, hdc, &sizl, PU_PELS | GPIT_MICRO | GPIA_ASSOC); bmih.cbFix = sizeof(bmih); bmih.cx = cx; bmih.cy = cy; bmih.cPlanes = 1; bmih.cBitCount = 24; bg = GpiCreateBitmap(hps, &bmih, 0L, NULL, NULL); GpiSetBitmap(hps,bg); /* Clear background */ rcl.xLeft = rcl.yBottom = 0; rcl.xRight = cx; rcl.yTop = cy; DBGTrace(cx); DBGTrace(cy); icqskin_paintBackground(hwnd,hps,&rcl); GpiSelectPalette(hps,NULLHANDLE); GpiSetColor(hps,CLR_WHITE); GpiSetBackColor(hps,CLR_BLACK); /* Stretch images */ y = cy; if(img[ICQFRAME_MIDSTRETCH] != NO_IMAGE) { if(img[ICQFRAME_TITLESTRETCH] != NO_IMAGE) { GpiQueryBitmapParameters(img[ICQFRAME_TITLESTRETCH], &bmpData); y -= bmpData.cy; } if(img[ICQFRAME_MIDLEFT] == NO_IMAGE) { x = 0; } else { GpiQueryBitmapParameters(img[ICQFRAME_MIDLEFT], &bmpData); x = bmpData.cx; } GpiQueryBitmapParameters(img[ICQFRAME_MIDSTRETCH], &bmpData); y -= bmpData.cy; do { for(f=x;f<cx;f+=bmpData.cx) drawFrameBG(img,msk, ICQFRAME_MIDSTRETCH, hps, f, y, bmpData.cx, bmpData.cy); y -= bmpData.cy; } while(y > 0); } if(img[ICQFRAME_TITLESTRETCH] != NO_IMAGE) { GpiQueryBitmapParameters(img[ICQFRAME_TITLESTRETCH], &bmpData); y = cy-bmpData.cy; for(x=0; x<cx; x += bmpData.cx) drawFrameBG(img,msk, ICQFRAME_TITLESTRETCH, hps, x, y, bmpData.cx, bmpData.cy); } if(img[ICQFRAME_MIDLEFT] != NO_IMAGE) { GpiQueryBitmapParameters(img[ICQFRAME_MIDLEFT], &bmpData); drawFrameBG(img,msk, ICQFRAME_MIDLEFT, hps, 0, 0, bmpData.cx, bmpData.cy); } if(img[ICQFRAME_MIDRIGHT] != NO_IMAGE) { GpiQueryBitmapParameters(img[ICQFRAME_MIDRIGHT], &bmpData); drawFrameBG(img,msk, ICQFRAME_MIDRIGHT, hps, cx-bmpData.cx, 0, bmpData.cx, bmpData.cy); } y = cy; if(img[ICQFRAME_TITLELEFT] != NO_IMAGE) { GpiQueryBitmapParameters(img[ICQFRAME_TITLELEFT], &bmpData); y -= bmpData.cy; drawFrameBG(img,msk, ICQFRAME_TITLELEFT, hps, 0, y, bmpData.cx, bmpData.cy); } if(img[ICQFRAME_TOPLEFT] != NO_IMAGE) { GpiQueryBitmapParameters(img[ICQFRAME_TOPLEFT], &bmpData); y -= bmpData.cy; drawFrameBG(img,msk, ICQFRAME_TOPLEFT, hps, 0, y, bmpData.cx, bmpData.cy); } if(img[ICQFRAME_MIDLEFT] != NO_IMAGE) { GpiQueryBitmapParameters(img[ICQFRAME_MIDLEFT], &bmpData); while(y > 0) { y -= bmpData.cy; drawFrameBG(img,msk, ICQFRAME_MIDLEFT, hps, 0, y, bmpData.cx, bmpData.cy); } } // Right images y = cy; if(img[ICQFRAME_TITLERIGHT] != NO_IMAGE) { GpiQueryBitmapParameters(img[ICQFRAME_TITLERIGHT], &bmpData); y -= bmpData.cy; drawFrameBG(img,msk, ICQFRAME_TITLERIGHT, hps, cx-bmpData.cx, y, bmpData.cx, bmpData.cy); } if(img[ICQFRAME_TOPRIGHT] != NO_IMAGE) { GpiQueryBitmapParameters(img[ICQFRAME_TOPRIGHT], &bmpData); y -= bmpData.cy; drawFrameBG(img,msk, ICQFRAME_TOPRIGHT, hps, cx-bmpData.cx, y, bmpData.cx, bmpData.cy); } if(img[ICQFRAME_MIDRIGHT] != NO_IMAGE) { GpiQueryBitmapParameters(img[ICQFRAME_MIDRIGHT], &bmpData); x = cx-bmpData.cx; while(y > 0) { y -= bmpData.cy; drawFrameBG(img,msk, ICQFRAME_MIDRIGHT, hps, x, y, bmpData.cx, bmpData.cy); } } // Bottom images if(img[ICQFRAME_BOTTOMSTRETCH] != NO_IMAGE) { GpiQueryBitmapParameters(img[ICQFRAME_BOTTOMSTRETCH], &bmpData); for(x=0; x<cx; x += bmpData.cx) drawFrameBG(img,msk, ICQFRAME_BOTTOMSTRETCH, hps, x, 0, bmpData.cx, bmpData.cy); } x = 0; if(img[ICQFRAME_BOTTOMLEFT] != NO_IMAGE) { GpiQueryBitmapParameters(img[ICQFRAME_BOTTOMLEFT], &bmpData); x += bmpData.cx; drawFrameBG(img,msk, ICQFRAME_BOTTOMLEFT, hps, 0, 0, bmpData.cx, bmpData.cy); } if(img[ICQFRAME_BOTTOMMIDLEFT] != NO_IMAGE) { GpiQueryBitmapParameters(img[ICQFRAME_BOTTOMMIDLEFT], &bmpData); drawFrameBG(img,msk, ICQFRAME_BOTTOMMIDLEFT, hps, x, 0, bmpData.cx, bmpData.cy); } x = cx; if(img[ICQFRAME_BOTTOMRIGHT] != NO_IMAGE) { GpiQueryBitmapParameters(img[ICQFRAME_BOTTOMRIGHT], &bmpData); x -= bmpData.cx; drawFrameBG(img,msk, ICQFRAME_BOTTOMRIGHT, hps, x, 0, bmpData.cx, bmpData.cy); } if(img[ICQFRAME_BOTTOMMIDRIGHT] != NO_IMAGE) { GpiQueryBitmapParameters(img[ICQFRAME_BOTTOMMIDRIGHT], &bmpData); x -= bmpData.cx; drawFrameBG(img,msk, ICQFRAME_BOTTOMMIDRIGHT, hps, x, 0, bmpData.cx, bmpData.cy); } /* Release image */ GpiSetBitmap(hps, NULLHANDLE); GpiDestroyPS(hps); DevCloseDC(hdc); return bg; #endif }
static HPOINTER combineTwoCursors(LONG idOver, LONG idUnder) { HPOINTER hptr = NULLHANDLE; POINTERINFO piOver, piUnder; HPOINTER hOver = WinQuerySysPointer(HWND_DESKTOP, idOver, FALSE); WinQueryPointerInfo(hOver, &piOver); HPOINTER hUnder = WinQuerySysPointer(HWND_DESKTOP, idUnder, FALSE); WinQueryPointerInfo(hUnder, &piUnder); if (piOver.hbmColor) { HPS hpsPtr, hpsTmp, hpsMask; HBITMAP hbmPtr, hbmTmp, hbmMask; qt_alloc_ps_with_bitmap(32, 32, false, hpsPtr, hbmPtr); qt_alloc_ps_with_bitmap(32, 32, false, hpsTmp, hbmTmp); qt_alloc_ps_with_bitmap(32, 64, true, hpsMask, hbmMask); // copy the overlying pointer POINTL ptls[] = { { 0, 0 }, { 31, 31 }, { 0, 0 }, { 32, 32 } }; GpiWCBitBlt(hpsTmp, piOver.hbmColor, 4, ptls, ROP_SRCCOPY, BBO_IGNORE); // make its transparent pixels black ptls[2].y += 32; ptls[3].y += 32; GpiSetColor(hpsTmp, CLR_TRUE); GpiSetBackColor(hpsTmp, CLR_FALSE); GpiWCBitBlt(hpsTmp, piOver.hbmPointer, 4, ptls, 0x22, BBO_IGNORE); // copy the underlying pointer ptls[2].y -= 32; ptls[3].y -= 32; GpiWCBitBlt(hpsPtr, piUnder.hbmColor, 4, ptls, ROP_SRCCOPY, BBO_IGNORE); // make non-transparent pixels from the overlying pointer black ptls[2].y += 32; ptls[3].y += 32; GpiSetColor(hpsPtr, CLR_TRUE); GpiSetBackColor(hpsPtr, CLR_FALSE); GpiWCBitBlt(hpsPtr, piOver.hbmPointer, 4, ptls, ROP_SRCAND, BBO_IGNORE); // put the overlying pointer there ptls[2].y -= 32; ptls[3].y -= 32; ptls[1].x ++; ptls[1].y ++; GpiBitBlt(hpsPtr, hpsTmp, 4, ptls, ROP_SRCPAINT, BBO_IGNORE); // copy both underlying pointer's masks ptls[1].x --; ptls[1].y --; ptls[1].y += 32; ptls[3].y += 32; GpiWCBitBlt(hpsMask, piUnder.hbmPointer, 4, ptls, ROP_SRCCOPY, BBO_IGNORE); // add overlying pointer's XOR mask ptls[1].y -= 32; ptls[3].y -= 32; GpiWCBitBlt(hpsMask, piOver.hbmPointer, 4, ptls, ROP_SRCPAINT, BBO_IGNORE); // add overlying pointer's AND mask ptls[0].y += 32; ptls[2].y += 32; ptls[1].y += 32; ptls[3].y += 32; GpiWCBitBlt(hpsMask, piOver.hbmPointer, 4, ptls, ROP_SRCAND, BBO_IGNORE); // create the new pointer GpiSetBitmap(hpsPtr, NULLHANDLE); GpiSetBitmap(hpsMask, NULLHANDLE); piOver.hbmColor = hbmPtr; piOver.hbmPointer = hbmMask; piOver.hbmMiniColor = NULLHANDLE; piOver.hbmMiniPointer = NULLHANDLE; hptr = WinCreatePointerIndirect(HWND_DESKTOP, &piOver); qt_free_ps_with_bitmap(hpsMask, hbmMask); qt_free_ps_with_bitmap(hpsTmp, hbmTmp); qt_free_ps_with_bitmap(hpsPtr, hbmPtr); } else { HPS hps; HBITMAP hbm; qt_alloc_ps_with_bitmap(32, 64, true, hps, hbm); POINTL ptls[] = { { 0, 0 }, { 31, 63 }, { 0, 0 }, { 32, 64 } }; // make a copy of the underlying pointer GpiWCBitBlt(hps, piUnder.hbmPointer, 4, ptls, ROP_SRCCOPY, BBO_IGNORE); // combine AND masks ptls[0].y += 32; ptls[2].y += 32; GpiWCBitBlt(hps, piOver.hbmPointer, 4, ptls, ROP_SRCAND, BBO_IGNORE); // apply the overlying AND mask to the underlying XOR mask ptls[0].y -= 32; ptls[1].y -= 32; GpiWCBitBlt(hps, piOver.hbmPointer, 4, ptls, ROP_SRCAND, BBO_IGNORE); // apply the overlying XOR mask to the underlying XOR mask ptls[2].y -= 32; ptls[3].y -= 32; GpiWCBitBlt(hps, piOver.hbmPointer, 4, ptls, ROP_SRCINVERT, BBO_IGNORE); // create the new pointer GpiSetBitmap(hps, 0); hptr = WinCreatePointer(HWND_DESKTOP, hbm, TRUE, piOver.xHotspot, piOver.yHotspot); qt_free_ps_with_bitmap(hps, hbm); } Q_ASSERT(hptr); return hptr; }
static MRESULT EXPENTRY MyWindowProc( HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2 ) { HPS hps; RECTL rc; switch( msg ) { case WM_CREATE: break; case WM_COMMAND: switch( SHORT1FROMMP( mp1 ) ) { case ID_UNLOCK: Say( "Unlocked" ); UnLockIt(); if( FocusWnd != NULL ) { WinSetFocus( HWND_DESKTOP, FocusWnd ); } WinSetActiveWindow( HWND_DESKTOP, hwndClient ); if( ActiveWnd != NULL ) { WinSetActiveWindow( HWND_DESKTOP, ActiveWnd ); } break; case ID_SWITCH: Say( "Switched" ); SwitchBack(); break; case ID_EXITPROG: WinPostMsg( hwnd, WM_CLOSE, (MPARAM)0, (MPARAM)0 ); break; default: return( WinDefWindowProc( hwnd, msg, mp1, mp2 ) ); } break; case WM_ERASEBACKGROUND: return( (MRESULT)TRUE ); case WM_PAINT: hps = WinBeginPaint( hwnd, 0L, &rc ); #ifdef DEBUG { POINTL pt; pt.x = 0; pt.y = 50; GpiSetColor( hps, CLR_NEUTRAL ); GpiSetBackColor( hps, CLR_BACKGROUND ); GpiSetBackMix( hps, BM_OVERPAINT ); GpiCharStringAt( hps, &pt, (LONG)strlen( Message ), Message ); } #endif WinEndPaint( hps ); break; case WM_CLOSE: WinPostMsg( hwnd, WM_QUIT, 0, 0 ); break; case WM_DESTROY: UnLockIt(); // fall thru default: return( WinDefWindowProc( hwnd, msg, mp1, mp2 ) ); } return( FALSE ); }
/************************************************************************** * * Name : MyWindowProc * * Description: The window procedure associated with the client area in * the standard frame window. It processes all messages * either sent or posted to the client area, depending on * the message command and parameters. * * Concepts : * * API's : WinLoadString * WinInvalidateRegion * WinPostMsg * WinDefWindowProc * WinBeginPaint * GpiSetColor * GpiSetBackColor * GpiSetBackMix * GpiCharStringAt * WinEndPaint * * Parameters : hwnd = window handle * msg = message code * mp1 = first message parameter * mp2 = second message parameter * * Return : depends on message sent * *************************************************************************/ MRESULT EXPENTRY MyWindowProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) { switch( msg ) { case WM_CREATE: /* * Window initialization is performed here in WM_CREATE processing * WinLoadString loads strings from the resource file. */ WinLoadString( hab, (HMODULE)0L, IDS_HELLO, STRINGLENGTH, szHello ); WinLoadString( hab, (HMODULE)0L, IDS_1, STRINGLENGTH, sz1 ); WinLoadString( hab, (HMODULE)0L, IDS_2, STRINGLENGTH, sz2 ); WinLoadString( hab, (HMODULE)0L, IDS_3, STRINGLENGTH, sz3 ); strcpy( szString, szHello ); /* Copy text Hello into szString*/ break; case WM_COMMAND: /* * When the user chooses option 1, 2, or 3 from the Options pull- * down, the text string is set to 1, 2, or 3, and * WinInvalidateRegion sends a WM_PAINT message. * When Exit is chosen, the application posts itself a WM_CLOSE * message. */ { USHORT command; /* WM_COMMAND command value */ command = SHORT1FROMMP(mp1); /* Extract the command value */ switch (command) { case ID_OPTION1: strcpy( szString, sz1 ); WinInvalidateRegion( hwnd, 0L, false ); LockIt(); break; case ID_OPTION2: strcpy( szString, sz2 ); WinInvalidateRegion( hwnd, 0L, false ); UnLockIt(); break; case ID_OPTION3: #pragma aux int3 = "int 3"; int3(); strcpy( szString, sz3 ); WinInvalidateRegion( hwnd, 0L, false ); break; case ID_EXITPROG: WinPostMsg( hwnd, WM_CLOSE, (MPARAM)0, (MPARAM)0 ); break; default: return WinDefWindowProc( hwnd, msg, mp1, mp2 ); } break; } case WM_ERASEBACKGROUND: /* * Return true to request PM to paint the window background * in SYSCLR_WINDOW. */ return (MRESULT)( true ); case WM_PAINT: /* * Window contents are drawn here in WM_PAINT processing. */ { HPS hps; /* Presentation Space handle */ RECTL rc; /* Rectangle coordinates */ POINTL pt; /* String screen coordinates */ char buff[256]; /* Create a presentation space */ sprintf( buff, "hab = %8.8x, hmq = %8.8x, hwnd = %8.8x", hab, hmq, hwnd ); hps = WinBeginPaint( hwnd, 0L, &rc ); pt.x = 0; pt.y = 50; /* Set the text coordinates, */ GpiSetColor( hps, CLR_NEUTRAL ); /* colour of the text, */ GpiSetBackColor( hps, CLR_BACKGROUND ); /* its background and */ GpiSetBackMix( hps, BM_OVERPAINT ); /* how it mixes, */ /* and draw the string...*/ GpiCharStringAt( hps, &pt, (LONG)strlen( buff ), buff ); WinEndPaint( hps ); /* Drawing is complete */ break; } case WM_CLOSE: /* * This is the place to put your termination routines */ WinPostMsg( hwnd, WM_QUIT, (MPARAM)0,(MPARAM)0 );/* Cause termination*/ break; default: /* * Everything else comes here. This call MUST exist * in your window procedure. */ return WinDefWindowProc( hwnd, msg, mp1, mp2 ); } return( (MRESULT)false ); } /* End of MyWindowProc */
/********************* Start of window procedure **********************/ MRESULT EXPENTRY MyWindowProc( HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2 ) { USHORT command; /* WM_COMMAND command value */ HPS hps; /* Presentation Space handle */ RECTL rc; /* Rectangle coordinates */ POINTL pt; /* String screen coordinates */ switch( msg ) { case WM_CREATE: if( State == RUNNING ) break; /******************************************************************/ /* Window initialization is performed here in WM_CREATE processing*/ /* WinLoadString loads strings from the resource file. */ /******************************************************************/ InitIt( "DSTD32", Hab, hwnd ); ReDraw( hwnd ); break; case WM_COMMAND: /******************************************************************/ /* When the user chooses option 1, 2, or 3 from the Options pull- */ /* down, the text string is set to 1, 2, or 3, and */ /* WinInvalidateRegion sends a WM_PAINT message. */ /* When Exit is chosen, the application posts itself a WM_CLOSE */ /* message. */ /******************************************************************/ command = SHORT1FROMMP(mp1); /* Extract the command value */ switch (command) { case ID_LOAD: if( State == RUNNING ) break; if( State != NONE ) { KillIt(); State = NONE; } if( LoadIt() ) { State = LOADED; } ReDraw( hwnd ); break; case ID_RUN: if( State == RUNNING ) break; State = RUNNING; ReDraw( hwnd ); if( InHardMode ) { WinLockInput( 0, FALSE ); InHardMode = FALSE; } State = RunIt() ? BROKE : TERMINATED; if( HardMode ) { WinLockInput( 0, TRUE ); InHardMode = TRUE; } ReDraw( hwnd ); break; case ID_KILL: if( State == RUNNING ) break; if( InHardMode ) { WinLockInput( 0, FALSE ); InHardMode = FALSE; } if( State != NONE ) { KillIt(); State = NONE; } ReDraw( hwnd ); break; case ID_HARD: if( State == RUNNING ) break; HardMode = !HardMode; TellHardMode( HardMode ? (char)-1 : 0 ); ReDraw( hwnd ); break; case ID_EXITPROG: if( InHardMode ) { WinLockInput( 0, FALSE ); InHardMode = FALSE; } if( State == RUNNING ) break; WinPostMsg( hwnd, WM_CLOSE, 0L, 0L ); break; default: return WinDefWindowProc( hwnd, msg, mp1, mp2 ); } break; case WM_ERASEBACKGROUND: /******************************************************************/ /* Return TRUE to request PM to paint the window background */ /* in SYSCLR_WINDOW. */ /******************************************************************/ return (MRESULT)( TRUE ); case WM_PAINT: /******************************************************************/ /* Window contents are drawn here in WM_PAINT processing. */ /******************************************************************/ /* Create a presentation space */ hps = WinBeginPaint( hwnd, NULL, &rc ); pt.x = 50; pt.y = 50; /* Set the text coordinates, */ GpiSetColor( hps, CLR_NEUTRAL ); /* colour of the text, */ GpiSetBackColor( hps, CLR_BACKGROUND ); /* its background and */ GpiSetBackMix( hps, BM_OVERPAINT ); /* how it mixes, */ /* and draw the string...*/ strcpy( WhatItIs[ State ] +HARD_POS, IsHardMode[ HardMode ] ); GpiCharStringAt( hps, &pt, (LONG)strlen( WhatItIs[ State ] ), WhatItIs[ State ] ); WinEndPaint( hps ); /* Drawing is complete */ break; case WM_CLOSE: /******************************************************************/ /* This is the place to put your termination routines */ /******************************************************************/ if( State == RUNNING ) break; FiniIt(); WinPostMsg( hwnd, WM_QUIT, 0L, 0L ); /* Cause termination */ break; default: /******************************************************************/ /* Everything else comes here. This call MUST exist */ /* in your window procedure. */ /******************************************************************/ return WinDefWindowProc( hwnd, msg, mp1, mp2 ); } return FALSE; }
MRESULT EXPENTRY windowproc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { HPS hps; RECTL rcl; DRAGITEM dit; PDRAGINFO pdin; HOBJECT hobj; static a=0; switch(msg) { /* control tray icon specific messages */ case DM_DROP: pdin = (PDRAGINFO)mp1; DrgAccessDraginfo(pdin); DrgQueryDragitem(pdin,sizeof(DRAGITEM),&dit,0); DrgQueryStrName(dit.hstrContainerName,256,cbuf); DrgQueryStrName(dit.hstrSourceName,256,buf); strcat(cbuf,buf); hobj=WinQueryObject("<WP_DRIVES>"); if(hobj)DosBeep(1000,100); //WinOpenObject(hobj,0,TRUE); WinMessageBox(HWND_DESKTOP,hwnd,"Drag Succeed!",cbuf,0,MB_OK | MB_INFORMATION); DrgFreeDraginfo(pdin); break; case DM_DRAGOVER: return MPFROM2SHORT(DOR_DROP,DO_LINK); case WM_TIMER: a++; a%=5; WinSendMsg(hwndFrame,WM_SETICON,(MPARAM)hIcon[a],NULL); ChangeTrayIcon(hwnd,NULLHANDLE); break; case WM_BUTTON1CLICK|0x2000: case WM_BUTTON2CLICK|0x2000: /* activate frame window */ WinSetWindowPos(hwndFrame,HWND_TOP,0,0,0,0,SWP_ACTIVATE | SWP_SHOW | SWP_ZORDER | SWP_RESTORE); break; case WM_CREATE: /* initialize window */ /* initialize tray api */ InitializeTrayApi(hwnd); break; case WM_DDE_INITIATEACK: /* aswer dde server */ AnswerTrayApiDdeAck(mp1); AddTrayIcon(hwnd,WinSendMsg(hwndFrame,WM_QUERYICON,NULL,NULL)); WinStartTimer(hab,hwnd,1,500); return (MRESULT)0L; case WM_PAINT: hps = WinBeginPaint(hwnd,NULL,NULL); WinQueryWindowRect(hwnd, &rcl); WinFillRect(hps, &rcl, CLR_CYAN); GpiSetColor(hps, CLR_DARKBLUE); GpiSetBackColor(hps, CLR_CYAN); rcl.xLeft=(rcl.xLeft+rcl.xRight)/2-40; rcl.yBottom=(rcl.yBottom+rcl.yTop)/2-7; GpiCharStringAt(hps, (PPOINTL)&rcl, 13, "Hello, world!"); WinEndPaint(hps); break; case WM_DESTROY: /* delete application icon from system tray */ return (MRESULT)DeleteTrayIcon(hwnd); } return WinDefWindowProc(hwnd, msg, mp1, mp2); }