From 0dddc09bc4516b164ebe49c783b6322dbc85257c Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Sun, 28 Mar 1999 12:40:43 +0000 Subject: [PATCH] Made libtest/hello3 work again, now with Windows-compatible resource loading. --- libtest/Makefile.in | 1 + libtest/hello3.c | 46 +++++++++++++++++++++++++++++--------------- libtest/hello3res.rc | 4 ++-- 3 files changed, 34 insertions(+), 17 deletions(-) diff --git a/libtest/Makefile.in b/libtest/Makefile.in index f93f344d9d7..ce721bf099f 100644 --- a/libtest/Makefile.in +++ b/libtest/Makefile.in @@ -6,6 +6,7 @@ MODULE = none RCFLAGS = -w32 -h PROGRAMS = expand hello hello2 hello3 hello4 hello5 new rolex vartest volinfo ALL_LIBS = $(WINELIB) $(X_LIBS) $(XLIB) $(LIBS) +WRCEXTRA = -A -p $* C_SRCS = \ expand.c \ diff --git a/libtest/hello3.c b/libtest/hello3.c index 6a75ff42066..ef22314267c 100644 --- a/libtest/hello3.c +++ b/libtest/hello3.c @@ -1,7 +1,16 @@ #include #include -#include "hello3res.h" #include +#include "hello3res.h" + +typedef struct +{ + HANDLE hInstance; + HWND hMainWnd; + HMENU hMainMenu; +} GLOBALS; + +GLOBALS Globals; BOOL FileOpen(HWND hWnd) { @@ -34,19 +43,26 @@ LRESULT WndProc (HWND wnd, UINT msg, WPARAM w, LPARAM l) case WM_COMMAND: switch(w){ case 100: - CreateDialogIndirect(0,hello3res_DIALOG_DIADEMO.bytes,wnd,(WNDPROC)DlgProc); + DialogBox(Globals.hInstance, + "DIADEMO", wnd, + (DLGPROC)DlgProc); return 0; case 101: { - BITMAPINFO *bm=(BITMAPINFO*)hello3res_BITMAP_BITDEMO.bytes; - char *bits=(char*)bm; - HDC hdc=GetDC(wnd); - bits+=bm->bmiHeader.biSize; - bits+=(1<bmiHeader.biBitCount)*sizeof(RGBQUAD); - SetDIBitsToDevice(hdc,0,0,bm->bmiHeader.biWidth, - bm->bmiHeader.biHeight,0,0,0,bm->bmiHeader.biHeight, - bits,bm,DIB_RGB_COLORS); - ReleaseDC(wnd,hdc); + HDC hdc, hMemDC; + HBITMAP hBitmap, hPrevBitmap; + BITMAP bmp; + + hBitmap = LoadBitmapA (Globals.hInstance, "BITDEMO"); + hdc = GetDC (wnd); + hMemDC = CreateCompatibleDC (hdc); + hPrevBitmap = SelectObject (hMemDC, hBitmap); + GetObjectA (hBitmap, sizeof(BITMAP), &bmp); + BitBlt (hdc, 0, 0, bmp.bmWidth, bmp.bmHeight, + hMemDC, 0, 0, SRCCOPY); + SelectObject (hMemDC, hPrevBitmap); + DeleteDC (hMemDC); + ReleaseDC (wnd, hdc); return 0; } case 102: @@ -67,12 +83,12 @@ LRESULT WndProc (HWND wnd, UINT msg, WPARAM w, LPARAM l) int PASCAL WinMain (HANDLE inst, HANDLE prev, LPSTR cmdline, int show) { - HWND wnd; MSG msg; WNDCLASS class; char className[] = "class"; /* To make sure className >= 0x10000 */ char winName[] = "Test app"; + Globals.hInstance = inst; if (!prev){ class.style = CS_HREDRAW | CS_VREDRAW; class.lpfnWndProc = WndProc; @@ -88,11 +104,11 @@ int PASCAL WinMain (HANDLE inst, HANDLE prev, LPSTR cmdline, int show) if (!RegisterClass (&class)) return FALSE; - wnd = CreateWindow (className, winName, WS_OVERLAPPEDWINDOW, + Globals.hMainWnd = CreateWindow (className, winName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 0, LoadMenu(inst,"MAIN"), inst, 0); - ShowWindow (wnd, show); - UpdateWindow (wnd); + ShowWindow (Globals.hMainWnd, show); + UpdateWindow (Globals.hMainWnd); while (GetMessage (&msg, 0, 0, 0)){ TranslateMessage (&msg); diff --git a/libtest/hello3res.rc b/libtest/hello3res.rc index e66c5a1680f..60ab44a94b4 100644 --- a/libtest/hello3res.rc +++ b/libtest/hello3res.rc @@ -1,4 +1,4 @@ -#include "windows.h" +#include MAIN MENU { @@ -9,7 +9,7 @@ MAIN MENU } } -/*BITDEMO BITMAP "../rc/winelogo.bmp"*/ +BITDEMO BITMAP "../rc/winelogo.bmp" DIADEMO DIALOG 20, 20, 179, 118 STYLE DS_MODALFRAME | WS_CAPTION | WS_POPUP | WS_VISIBLE | WS_SYSMENU