Yes I do register the class but I took that out cause I didn't think you needed to see it but:
Code:
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ;
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) GetStockObject (BLACK_BRUSH) ;
wndclass.lpszMenuName = "MENUDEMO" ;
wndclass.lpszClassName = szAppName ;
if (!RegisterClass (&wndclass))
{
MessageBox (NULL, TEXT ("This program requires Windows NT!"),
szAppName, MB_ICONERROR) ;
return 0 ;
}
wndclass.lpfnWndProc = ChildWndProc ;
wndclass.hIcon = NULL ;
wndclass.lpszClassName = "Child_SCTS" ;
wndclass.cbWndExtra = sizeof (long) ;
if (!RegisterClass (&wndclass))
{
MessageBox (NULL, TEXT ("This program requires Windows NT!"),
szAppName, MB_ICONERROR) ;
return 0 ;
}
I tried your createwindow command, worked once and the loadbitmap failed. I copied your bitmap line and its giving me
Code:
Error: scts.c(242,64):Undefined symbol 'IDB_568a'
the line is the load bitmap line.
I readded the quotations around IDB_568a and re compiled now I am back to where I started with createwindow failing. Im starting to remember why I stopped programming.
The new createwindow call is
Code:
MessageBox (NULL, TEXT ("The menu works."), TEXT ("Hellomsg")
, 0);
hwndChild = CreateWindow ("Child_SCTS", TEXT("Wiring diagram"),
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_VISIBLE, 0, 0, 282, 363,hwnd, NULL,
hInstance, NULL);
if (hwndChild == NULL) {
char buf[256];
sprintf(buf, "CreateWindow failed with %d", GetLastError());
MessageBoxA(NULL, buf, NULL, 0);
}
return 0;
The Load bitmap section is(I haven't fixed the GDI leak yet, fix the problem before causing new ones)
Code:
static HBITMAP hBitmap;
static int cxClient, cyClient, cxSource, cySource ;
BITMAP bitmap;
HDC hdc, hdcmem;
HINSTANCE hInstance;
int x,y;
PAINTSTRUCT ps;
switch (message)
{
case WM_CREATE :
hInstance = ((LPCREATESTRUCT) lParam)->hInstance;
hBitmap = LoadBitmap (hInstance,MAKEINTRESOURCE(IDB_568a));
if (hBitmap == NULL) {
char buf[256];
sprintf(buf, "LoadBitmap failed with %d", GetLastError());
MessageBoxA(NULL, buf, NULL, 0);
}
GetObject (hBitmap, sizeof (BITMAP), &bitmap);
cxSource = bitmap.bmWidth;
cySource = bitmap.bmHeight;
return 0;
case WM_PAINT:
hdc = BeginPaint (hwnd, &ps) ;
hdcmem = CreateCompatibleDC (hdc) ;
SelectObject (hdcmem, hBitmap);
for (y = 0 ; y < cyClient ; y += cySource)
for (x = 0 ; x < cxClient ; x += cxSource)
{
BitBlt (hdc, x, y, cxSource, cySource, hdcmem, 0, 0, SRCCOPY) ;
}
DeleteDC (hdcmem);
EndPaint (hwnd, &ps);
return 0;
I hope thats enough code, if not I attached the source code file, resource file and resource header. Its all setup for Borland 5.0 IDE compiler.