I have been going thru the resource tutorial on this site
Here... I dont know if it is this tutorial or me.. or what... cuase ne thing i do with this tutorial DONT WORK!!!!.... My resource file here:
#include "resource.h"
ICON_MAIN ICON myicon.ico
CURSOR_ARROW CURSOR arrow.cur
my header file here:
#define ICON_MAIN 1000
#define CURSOR_ARROW 2000
My load icon/cursor statements
HICON LoadIcon(
HINSTANCE hInstance, // handle to application instance
LPCTSTR lpIconName // icon-name string or icon resource identifier
);
HCURSOR LoadCursor(
HINSTANCE hInstance, // handle to application instance
LPCTSTR lpCursorName // name string or cursor resource identifier
);
my main file(non edited ):
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
const char className[] = "Sample Class";
const char windowName[] = "Sample Window";
LRESULT CALLBACK MsgHandler(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
int WINAPI WinMain( HINSTANCE hinstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
WNDCLASSEX sampleClass;
MSG msg; HWND hwnd;
sampleClass.cbSize = sizeof(WNDCLASSEX);
sampleClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
sampleClass.lpfnWndProc = MsgHandler;
sampleClass.cbClsExtra = 0;
sampleClass.cbWndExtra = 0;
sampleClass.hInstance = hinstance;
sampleClass.hIcon = LoadIcon(NULL, IDI_WINLOGO);
sampleClass.hCursor = LoadCursor(NULL, IDC_ARROW);
sampleClass.hbrBackground = (HBRUSH)(GRAY_BRUSH);
sampleClass.lpszMenuName = NULL;
sampleClass.lpszClassName = className;
sampleClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
if(!RegisterClassEx(&sampleClass))
{
MessageBox(NULL, "Could not register window class.", "ERROR", MB_OK);
return 0;
}
hwnd = CreateWindowEx( 0,
className,
windowName,
WS_POPUP | WS_VISIBLE,
0, 0, 800, 600,
NULL,
NULL,
hinstance,
NULL);
if(hwnd == NULL)
{
MessageBox(NULL, "Could not create window.", "ERROR", MB_OK);
return 0;
}
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
while(1)
{
if(PeekMessage(&msg,
NULL,
0,
0,
PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else if(msg.message == WM_QUIT)
{
break;
}
}
UnregisterClass(className, hinstance);
return msg.wParam;
}
LRESULT CALLBACK MsgHandler(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
switch(msg)
{
case WM_DESTROY:
{
PostQuitMessage(0);
}
break;
default:
{
return DefWindowProc(hwnd, msg, wparam, lparam);
}
}
return 0;}
WTF is my problem... where do i put sum of this stuff.. cuase this dont tell me much(no i am not just a noob that copies and pastes code i read through it)....
when i add all of it together:i get this:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "rsrc.rc"
const char className[] = "new class";
const char windowName[] = "new Window";
LRESULT CALLBACK MsgHandler(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
int WINAPI WinMain( HINSTANCE hinstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
WNDCLASSEX sampleClass;
MSG msg; HWND hwnd;
sampleClass.cbSize = sizeof(WNDCLASSEX);
sampleClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
sampleClass.lpfnWndProc = MsgHandler;
sampleClass.cbClsExtra = 0;
sampleClass.cbWndExtra = 0;
sampleClass.hInstance = hinstance;
sampleClass.hIcon = LoadIcon(hinstance, "ICON_MAIN");
sampleClass.hCursor = LoadIcon(hinstance, "CUSOR_ARROW");
sampleClass.hbrBackground = (HBRUSH)(GRAY_BRUSH);
sampleClass.lpszMenuName = NULL;
sampleClass.lpszClassName = className;
sampleClass.hIcon = LoadIcon(hinstance, "ICON_MAIN");
HICON LoadIcon(
HINSTANCE hInstance, // handle to application instance
LPCTSTR lpIconName // icon-name string or icon resource identifier
);
HCURSOR LoadCursor(
HINSTANCE hInstance, // handle to application instance
LPCTSTR lpCursorName // name string or cursor resource identifier
);
if(!RegisterClassEx(&sampleClass))
{
MessageBox(NULL, "Could not register window class.", "ERROR", MB_OK);
return 0;
}
hwnd = CreateWindowEx( 0,
className,
windowName,
WS_POPUP | WS_VISIBLE,
0, 0, 800, 600,
NULL,
NULL,
hinstance,
NULL);
if(hwnd == NULL)
{
MessageBox(NULL, "Could not create window.", "ERROR", MB_OK);
return 0;
}
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
while(1)
{
if(PeekMessage(&msg,
NULL,
0,
0,
PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else if(msg.message == WM_QUIT)
{
break;
}
}
UnregisterClass(className, hinstance);
return msg.wParam;
}
LRESULT CALLBACK MsgHandler(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
switch(msg)
{
case WM_DESTROY:
{
PostQuitMessage(0);
}
break;
default:
{
return DefWindowProc(hwnd, msg, wparam, lparam);
}
}
return 0;
}
[edited by - TheNerd Tk421 on August 13, 2003 4:35:19 PM]