home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 11 Util
/
11-Util.zip
/
BMAP01.ZIP
/
BMAP01.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-01-21
|
8KB
|
247 lines
//█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█
//█ Module.....: bmap01.c █
//█ Date.......: Thu Jan 21 14:36:32 1993 █
//█ Version....: 1.0 █
//█ Author.....: Wade A. Deuter / Progressive Software Technologies, Inc. █
//█ █
//█ Description: Bitmap Sample - Display Bitmap In A Window █
//█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█
//
// Window Coordinates
//
#define EXTERN
#define TOP 550
#define LEFT 0
#define BOTTOM 0
#define RIGHT 750
#include "BMAP01.h"
HDC hdc,
hdcMemory;
HPS hps,
hpsMemory;
LONG alBmpFormats[2];
HBITMAP hbmSrc;
LONG lcxMinMax,
lcyMinMax;
SHORT sGridy,
sGridx,
sMoveVar,
sxPels,
syPels;
BOOL FirstTime = 1;
SIZEL sizl;
SIZEL NewSizl;
BITMAPINFOHEADER bmp;
POINTL aptl[4];
HPS hpsd;
RECTL rclInvalid,
WinSize;
int Width = RIGHT - LEFT,
Height = TOP - BOTTOM;
int main( void )
{
QMSG qmsg;
INT rc;
ULONG ctldata;
if((hAB = WinInitialize(0)) == 0)
return(FALSE);
if((hMQ = WinCreateMsgQueue(hAB, 0)) == 0)
return(FALSE);
rc = WinRegisterClass(hAB, // Anchor block handle
(PCH)"BMAP01", // Name of class being registered
(PFNWP)WndProc, // Window procedure for class
CS_SIZEREDRAW ,
0); // Extra bytes to reserve
if (rc == FALSE)
return(FALSE);
ctldata = FCF_TITLEBAR |
FCF_SYSMENU |
FCF_MINBUTTON |
FCF_MAXBUTTON |
FCF_SIZEBORDER |
FCF_MENU |
FCF_SHELLPOSITION;
hWndFrame = WinCreateStdWindow(HWND_DESKTOP, // parent of window
0L, // frame window style
&ctldata, // frame flags
"BMAP01", // class name
"BMAP01", // window title
0L, // client window style
0, // module for resources
ID_BMAP01, // resource id
(HWND FAR *)&hWndClient); // client handle
if(hWndFrame == 0)
return(FALSE);
//
// Window was not displayed because frame window style was specified as 0L,
// so here we size it and make it visible
//
WinSetWindowPos( hWndFrame, HWND_TOP, LEFT, BOTTOM, RIGHT, TOP, SWP_SIZE | SWP_MOVE | SWP_SHOW);
while(WinGetMsg(hAB, (PQMSG)&qmsg, 0, 0, 0))
WinDispatchMsg(hAB,(PQMSG)&qmsg);
WinDestroyWindow(hWndFrame);
WinDestroyMsgQueue(hMQ);
WinTerminate(hAB);
}
//┌──────────────────────────────────────────────────────────────────────────┐
//│ Function...: WndProc │
//│ Date.......: Wed Jan 20 10:34:17 1993 │
//│ Author.....: Wade A. Deuter │
//│ │
//│ Description: │
//└──────────────────────────────────────────────────────────────────────────┘
MRESULT EXPENTRY WndProc(HWND hWnd, USHORT message, MPARAM mp1, MPARAM mp2)
{
HPS hps;
static HBITMAP Bitmap;
RECTL Rect,
rcl,
WinSize;
USHORT rc;
switch(message)
{
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case IDM_H_ABOUT:
rc = WinDlgBox(HWND_DESKTOP,
hWnd,
(PFNWP)BMAPABTMsgProc,
0,
IDLG_BMAPABT,
NULL);
break;
default:
break;
}
break;
case WM_SIZE:
//
// Load Bitmap and get ready to use it
//
WinSetPointer (HWND_DESKTOP,
WinQuerySysPointer (HWND_DESKTOP, SPTR_WAIT, FALSE));
WinQueryWindowRect (hWnd, &WinSize);
Width = WinSize.xRight - WinSize.xLeft;
Height = WinSize.yTop - WinSize.yBottom;
hps = WinGetPS( hWnd );
Bitmap = GpiLoadBitmap( hps, (USHORT)NULL, ID_LOGO, Width, Height );
WinReleasePS( hps );
WinSetPointer (HWND_DESKTOP,
WinQuerySysPointer (HWND_DESKTOP, SPTR_ARROW, FALSE));
break;
case WM_CREATE:
//
// Load Bitmap and get ready to use it
//
hps = WinGetPS( hWnd );
Bitmap = GpiLoadBitmap( hps, (USHORT)NULL, ID_LOGO, Width, Height );
WinReleasePS( hps );
break;
case WM_PAINT:
//
// Draw Bitmap In Window
//
hps = WinBeginPaint (hWnd, (HPS) NULL, &Rect);
WinQueryWindowRect (hWnd, &rcl);
WinSetPointer (HWND_DESKTOP,
WinQuerySysPointer (HWND_DESKTOP, SPTR_WAIT, FALSE));
WinDrawBitmap (hps,
Bitmap,
NULL,
(PPOINTL) &rcl,
CLR_BLACK,
CLR_BLACK,
DBM_NORMAL);
WinSetPointer (HWND_DESKTOP,
WinQuerySysPointer (HWND_DESKTOP, SPTR_ARROW, FALSE));
WinEndPaint (hps);
return(MRESULT)FALSE;
case WM_DESTROY:
GpiDeleteBitmap( Bitmap );
return(MRESULT)NULL;
default:
return(WinDefWindowProc(hWnd, message, mp1, mp2));
break;
}
return(0L);
}
//┌──────────────────────────────────────────────────────────────────────────┐
//│ Function...: BMAPABTMsgProc │
//│ Date.......: Wed Jan 20 10:34:41 1993 │
//│ Author.....: Wade A. Deuter │
//│ │
//│ Description: │
//└──────────────────────────────────────────────────────────────────────────┘
MRESULT EXPENTRY BMAPABTMsgProc(HWND hWndDlg, USHORT message, MPARAM mp1, MPARAM mp2)
{
switch(message)
{
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case DID_OK:
WinDismissDlg(hWndDlg, TRUE);
break;
}
break;
case WM_CLOSE:
WinDismissDlg(hWndDlg, FALSE);
break;
case WM_FAILEDVALIDATE:
return((MRESULT)TRUE);
break;
default:
return(WinDefDlgProc(hWndDlg, message, mp1, mp2));
break;
}
return FALSE;
}