Made libtest/hello3 work again, now with Windows-compatible resource

loading.
This commit is contained in:
Pavel Roskin 1999-03-28 12:40:43 +00:00 committed by Alexandre Julliard
parent 2840d1b7a9
commit 0dddc09bc4
3 changed files with 34 additions and 17 deletions

View File

@ -6,6 +6,7 @@ MODULE = none
RCFLAGS = -w32 -h RCFLAGS = -w32 -h
PROGRAMS = expand hello hello2 hello3 hello4 hello5 new rolex vartest volinfo PROGRAMS = expand hello hello2 hello3 hello4 hello5 new rolex vartest volinfo
ALL_LIBS = $(WINELIB) $(X_LIBS) $(XLIB) $(LIBS) ALL_LIBS = $(WINELIB) $(X_LIBS) $(XLIB) $(LIBS)
WRCEXTRA = -A -p $*
C_SRCS = \ C_SRCS = \
expand.c \ expand.c \

View File

@ -1,7 +1,16 @@
#include <windows.h> #include <windows.h>
#include <resource.h> #include <resource.h>
#include "hello3res.h"
#include <commdlg.h> #include <commdlg.h>
#include "hello3res.h"
typedef struct
{
HANDLE hInstance;
HWND hMainWnd;
HMENU hMainMenu;
} GLOBALS;
GLOBALS Globals;
BOOL FileOpen(HWND hWnd) BOOL FileOpen(HWND hWnd)
{ {
@ -34,19 +43,26 @@ LRESULT WndProc (HWND wnd, UINT msg, WPARAM w, LPARAM l)
case WM_COMMAND: case WM_COMMAND:
switch(w){ switch(w){
case 100: case 100:
CreateDialogIndirect(0,hello3res_DIALOG_DIADEMO.bytes,wnd,(WNDPROC)DlgProc); DialogBox(Globals.hInstance,
"DIADEMO", wnd,
(DLGPROC)DlgProc);
return 0; return 0;
case 101: case 101:
{ {
BITMAPINFO *bm=(BITMAPINFO*)hello3res_BITMAP_BITDEMO.bytes; HDC hdc, hMemDC;
char *bits=(char*)bm; HBITMAP hBitmap, hPrevBitmap;
HDC hdc=GetDC(wnd); BITMAP bmp;
bits+=bm->bmiHeader.biSize;
bits+=(1<<bm->bmiHeader.biBitCount)*sizeof(RGBQUAD); hBitmap = LoadBitmapA (Globals.hInstance, "BITDEMO");
SetDIBitsToDevice(hdc,0,0,bm->bmiHeader.biWidth, hdc = GetDC (wnd);
bm->bmiHeader.biHeight,0,0,0,bm->bmiHeader.biHeight, hMemDC = CreateCompatibleDC (hdc);
bits,bm,DIB_RGB_COLORS); hPrevBitmap = SelectObject (hMemDC, hBitmap);
ReleaseDC(wnd,hdc); 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; return 0;
} }
case 102: 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) int PASCAL WinMain (HANDLE inst, HANDLE prev, LPSTR cmdline, int show)
{ {
HWND wnd;
MSG msg; MSG msg;
WNDCLASS class; WNDCLASS class;
char className[] = "class"; /* To make sure className >= 0x10000 */ char className[] = "class"; /* To make sure className >= 0x10000 */
char winName[] = "Test app"; char winName[] = "Test app";
Globals.hInstance = inst;
if (!prev){ if (!prev){
class.style = CS_HREDRAW | CS_VREDRAW; class.style = CS_HREDRAW | CS_VREDRAW;
class.lpfnWndProc = WndProc; class.lpfnWndProc = WndProc;
@ -88,11 +104,11 @@ int PASCAL WinMain (HANDLE inst, HANDLE prev, LPSTR cmdline, int show)
if (!RegisterClass (&class)) if (!RegisterClass (&class))
return FALSE; return FALSE;
wnd = CreateWindow (className, winName, WS_OVERLAPPEDWINDOW, Globals.hMainWnd = CreateWindow (className, winName, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 0, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 0,
LoadMenu(inst,"MAIN"), inst, 0); LoadMenu(inst,"MAIN"), inst, 0);
ShowWindow (wnd, show); ShowWindow (Globals.hMainWnd, show);
UpdateWindow (wnd); UpdateWindow (Globals.hMainWnd);
while (GetMessage (&msg, 0, 0, 0)){ while (GetMessage (&msg, 0, 0, 0)){
TranslateMessage (&msg); TranslateMessage (&msg);

View File

@ -1,4 +1,4 @@
#include "windows.h" #include <windows.h>
MAIN MENU MAIN MENU
{ {
@ -9,7 +9,7 @@ MAIN MENU
} }
} }
/*BITDEMO BITMAP "../rc/winelogo.bmp"*/ BITDEMO BITMAP "../rc/winelogo.bmp"
DIADEMO DIALOG 20, 20, 179, 118 DIADEMO DIALOG 20, 20, 179, 118
STYLE DS_MODALFRAME | WS_CAPTION | WS_POPUP | WS_VISIBLE | WS_SYSMENU STYLE DS_MODALFRAME | WS_CAPTION | WS_POPUP | WS_VISIBLE | WS_SYSMENU