Thread: Script errors - bool unrecognized and struct issues

  1. #1
    Math wizard
    Join Date
    Dec 2006
    Location
    USA
    Posts
    582

    Script errors - bool unrecognized and struct issues

    I'm compiling my Windows code as C however, I'm running into two problems. One of the errors I'm getting is where "bool" is an undeclared identifier even though it's highlighted as blue in Visual C++ 2005 Express. It's also not recognizing the "done" thing either as that's the name of the boolean variable. The other is that it's not recognizing my struct creations (line #156) saying it must have a struct/union type - uh, it does (or at least I think it does given this).

    Code:
    // First Windows app.cpp : Defines the entry point for the application.
    /*
    To do before making the first useful Windows application - what background scaling is (or "The Supernatural Olympics" version 1.1):
    Draw images
    Syncronize drawing images with monitor refresh rate
    Call a function upon pressing a key
    */
    
    /*	Trim fat from windows*/
    #define WIN32_LEAN_AND_MEAN	
    #pragma comment(linker, "/subsystem:windows")
    /*	Pre-processor directives*/
    #include "stdafx.h"
    #include "Vfw.h"
    #include <stdio.h>
    #include <windows.h>
    
    // defines and global vars
    
    struct coord_short_xy
    {
    	short x;
    	short y;
    };
    
    /*
    short screen_size[2]; // screen resolution (e.g. 1920x1440)
    short window_size_base[2]; // expected window size
    short window_size[2]; // actual window size
    short window_pos[2]; // window position
    short window_border[2]; // size of the window border
    */
    short title_bar_height; // height of the title bar in pixels
    
    FILE *file_handle; // handle for reading/writing files
    char bmp_image[]; // data for the bitmap image
    
    HDRAWDIB img_handle; // pointer for a DrawDib handle
    HWND hwnd; // window handle
    HDC HDC_handle; // pointer for HDC handle
    WNDCLASSEX windowClass; // for a window class
    MSG msg; // a message for windows
    
    LPBITMAPINFOHEADER bmp_head_pointer;
    LPVOID bmp_image_pointer;
    BITMAPFILEHEADER bmp_filehead;
    BITMAPINFOHEADER bmp_head;
    
    void draw_test_image()
    {
    	img_handle = DrawDibOpen();
    	
    	file_handle = fopen("C:\\My Documents\\My programs\\ulillilliacity.bmp", "rb"); // read the source BMP file to display, binary mode
    	// fopen_s(file_handle, "C:\\My Documents\\My programs\\ulillilliacity.bmp", "rb"); // causes unexplained warning - 'FILE **' differs in levels of indirection from 'FILE *'
    	// fseek(file_handle, 2, seek_set); // skip the first two bytes, the file identifier, the string "BM"
    	// fill the bitmap file header struct reading from the file
    	fread(&bmp_filehead.bfType, 2, 1, file_handle);
    	fread(&bmp_filehead.bfSize, 4, 1, file_handle);
    	fread(&bmp_filehead.bfReserved1, 2, 1, file_handle);
    	fread(&bmp_filehead.bfReserved2, 2, 1, file_handle);
    	fread(&bmp_filehead.bfOffBits, 4, 1, file_handle);
    	
    	// fill the bitmap info header struct reading from the file
    	fread(&bmp_head.biSize, 4, 1, file_handle); // actual file size
    	fread(&bmp_head.biWidth, 4, 1, file_handle);
    	fread(&bmp_head.biHeight, 4, 1, file_handle);
    	fread(&bmp_head.biPlanes, 2, 1, file_handle);
    	fread(&bmp_head.biBitCount, 2, 1, file_handle);
    	fread(&bmp_head.biCompression, 4, 1, file_handle);
    	fread(&bmp_head.biSizeImage, 4, 1, file_handle);
    	fread(&bmp_head.biXPelsPerMeter, 4, 1, file_handle);
    	fread(&bmp_head.biYPelsPerMeter, 4, 1, file_handle);
    	fread(&bmp_head.biClrUsed, 4, 1, file_handle);
    	fread(&bmp_head.biClrImportant, 4, 1, file_handle);
    	// fread(&bmp_head.biClrImportant, 4, 1, file_handle);
    	fread(&bmp_image, 1, bmp_head.biSizeImage, file_handle); // read the remainder of the bits, the image data part
    	fclose(file_handle);
    	
    	DrawDibDraw(img_handle, HDC_handle, 0, 0, bmp_head.biWidth, bmp_head.biHeight, bmp_head_pointer, bmp_image_pointer, 64, 48, 512, 384, 0);
    	DrawDibClose(img_handle); // free the resources
    	ReleaseDC(hwnd, HDC_handle); // free the DC handle
    }
    
    /* Windows Procedure Event Handler */
    LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    	PAINTSTRUCT paintStruct;
    	/* Device Context */
    	HDC hDC; // local HDC declaration
    	/* Text for display */
    	char string[] = "Image test - there should be an image below"; 
    	/* Switch message, condition that is met will execute */
    	switch(message)
    	{
    		/* Window is being created */
    		case WM_CREATE: 
    			return 0;
    			break;
    		/* Window is closing */
    		case WM_CLOSE: 
    			PostQuitMessage(0);
    			return 0;
    			break;
    		/* Window needs update */
    		case WM_PAINT: 
    			hDC = BeginPaint(hwnd,&paintStruct);
    			/* Set txt color to sky blue */
    			SetTextColor(hDC, 0x00FF8040);
    			/* Display text in middle of window */
    			TextOut(hDC,0,2,string,sizeof(string)-1);
    			EndPaint(hwnd, &paintStruct);
    			return 0;
    			break;
    		default:
    			break;
    	}
    	return (DefWindowProc(hwnd,message,wParam,lParam));
    }
    
    int APIENTRY WinMain(HINSTANCE hInstance,
                         HINSTANCE hPrevInstance,
                         LPSTR     lpCmdLine,
                         int       nCmdShow)
    {
    	bool done; // flag saying when app is complete - undeclared identifier
    	/* Fill out the window class structure */
    	windowClass.cbSize = sizeof(WNDCLASSEX);
    	windowClass.style = CS_HREDRAW | CS_VREDRAW;
    	windowClass.lpfnWndProc = WndProc;
    	windowClass.cbClsExtra = 0;
    	windowClass.cbWndExtra = 0;
    	windowClass.hInstance = hInstance;
    	windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    	windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
    	windowClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
    	windowClass.lpszMenuName = NULL;
    	windowClass.lpszClassName = "MyClass";
    	windowClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
    	/* Register window class */
    	if (!RegisterClassEx(&windowClass))
    	{
    		return 0;
    	}
    	
    	/* SM_CXBORDER is 1
    	SM_CYBORDER is 1
    	SM_CXEDGE is 2
    	SM_CYEDGE is 2
    	SM_CXFIXEDFRAME is 3
    	SM_CYFIXEDFRAME is 3
    	SM_CXSIZEFRAME is 4
    	SM_CYSIZEFRAME is 4
    	SM_CYCAPTION is 18
    	*/
    	
    	struct coord_short_xy window_border; // line #156 - missing semicolon before type?  There's no missing semicolon.
    	struct coord_short_xy screen_size;
    	struct coord_short_xy window_size_base;
    	struct coord_short_xy window_size;
    	struct coord_short_xy window_pos;
    	
    	window_border.x = GetSystemMetrics(SM_CXSIZEFRAME); // obtain border sizes, title bar height, and operating resolution
    	window_border.y = GetSystemMetrics(SM_CYSIZEFRAME);
    	title_bar_height = GetSystemMetrics(SM_CYCAPTION); // obtain height of the title bar
    	screen_size.x = GetSystemMetrics(SM_CXSCREEN); // operating resolution
    	screen_size.y = GetSystemMetrics(SM_CYSCREEN);
    	window_size_base.x = 640; // interior window size
    	window_size_base.y = 480;
    	window_size.x = window_size_base.x+window_border.x*2; // full window size, including borders and title bar
    	window_size.y = window_size_base.y+window_border.y*2+title_bar_height;
    	window_pos.x = (screen_size.x/2)-(window_size.x/2); // center the window
    	window_pos.y = (screen_size.y/2)-(window_size.y/2);
    	
    	/* Class registerd, so now create window */
    	hwnd = CreateWindowEx(NULL,		// extended style
    		"MyClass",			// class name
    		"First Windows app",		// app name
    		WS_OVERLAPPEDWINDOW |		// window style
    		WS_VISIBLE |
    		WS_SYSMENU,
    		window_pos.x,window_pos.y,			// x/y coords
    		window_size.x,window_size.y,			// width,height
    		NULL,				// handle to parent
    		NULL,				// handle to menu
    		hInstance,			// application instance
    		NULL);				// no extra parameter's
    	/* Check if window creation failed */
    	if (!hwnd)
    		return 0;
    	done = false; // initialize loop condition variable
    	/* main message loop */
    	
    	HDC_handle = GetDC(hwnd);
    	
    	draw_test_image();
    	
    	while(!done)
    	{
    		PeekMessage(&msg,hwnd,NULL,NULL,PM_REMOVE);
    		if (msg.message == WM_QUIT) // check for a quit message
    		{
    			done = true; // if found, quit app
    		}
    		else
    		{
    			/* Translate and dispatch to event queue */
    			TranslateMessage(&msg); 
    			DispatchMessage(&msg);
    		}
    	}
    	return msg.wParam;
    }
    The build log shows this (skipping the first one as it says fopen is deprecated) - note the numerous errors saying the same thing:

    c:\my documents\my programs\first windows app\first windows app\first windows app.c(125) : error C2065: 'bool' : undeclared identifier
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(125) : error C2146: syntax error : missing ';' before identifier 'done'
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(125) : error C2065: 'done' : undeclared identifier
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(156) : error C2143: syntax error : missing ';' before 'type'
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(157) : error C2143: syntax error : missing ';' before 'type'
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(158) : error C2143: syntax error : missing ';' before 'type'
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(159) : error C2143: syntax error : missing ';' before 'type'
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(160) : error C2143: syntax error : missing ';' before 'type'
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(162) : error C2065: 'window_border' : undeclared identifier
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(162) : error C2224: left of '.x' must have struct/union type
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(163) : error C2224: left of '.y' must have struct/union type
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(165) : error C2065: 'screen_size' : undeclared identifier
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(165) : error C2224: left of '.x' must have struct/union type
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(166) : error C2224: left of '.y' must have struct/union type
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(167) : error C2065: 'window_size_base' : undeclared identifier
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(167) : error C2224: left of '.x' must have struct/union type
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(168) : error C2224: left of '.y' must have struct/union type
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(169) : error C2065: 'window_size' : undeclared identifier
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(169) : error C2224: left of '.x' must have struct/union type
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(169) : error C2224: left of '.x' must have struct/union type
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(169) : error C2224: left of '.x' must have struct/union type
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(170) : error C2224: left of '.y' must have struct/union type
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(170) : error C2224: left of '.y' must have struct/union type
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(170) : error C2224: left of '.y' must have struct/union type
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(171) : error C2065: 'window_pos' : undeclared identifier
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(171) : error C2224: left of '.x' must have struct/union type
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(171) : error C2224: left of '.x' must have struct/union type
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(171) : error C2224: left of '.x' must have struct/union type
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(172) : error C2224: left of '.y' must have struct/union type
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(172) : error C2224: left of '.y' must have struct/union type
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(172) : error C2224: left of '.y' must have struct/union type
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(175) : warning C4047: 'function' : 'DWORD' differs in levels of indirection from 'void *'
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(175) : warning C4024: 'CreateWindowExA' : different types for formal and actual parameter 1
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(181) : error C2224: left of '.x' must have struct/union type
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(181) : error C2224: left of '.y' must have struct/union type
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(182) : error C2224: left of '.x' must have struct/union type
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(182) : error C2224: left of '.y' must have struct/union type
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(183) : warning C4047: 'function' : 'int' differs in levels of indirection from 'void *'
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(183) : warning C4024: 'CreateWindowExA' : different types for formal and actual parameter 5
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(184) : warning C4047: 'function' : 'int' differs in levels of indirection from 'void *'
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(184) : warning C4024: 'CreateWindowExA' : different types for formal and actual parameter 6
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(185) : warning C4047: 'function' : 'int' differs in levels of indirection from 'HINSTANCE'
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(185) : warning C4024: 'CreateWindowExA' : different types for formal and actual parameter 7
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(186) : warning C4047: 'function' : 'int' differs in levels of indirection from 'void *'
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(186) : warning C4024: 'CreateWindowExA' : different types for formal and actual parameter 8
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(186) : error C2198: 'CreateWindowExA' : too few arguments for call
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(190) : error C2065: 'false' : undeclared identifier
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(199) : warning C4047: 'function' : 'UINT' differs in levels of indirection from 'void *'
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(199) : warning C4024: 'PeekMessageA' : different types for formal and actual parameter 3
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(199) : warning C4047: 'function' : 'UINT' differs in levels of indirection from 'void *'
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(199) : warning C4024: 'PeekMessageA' : different types for formal and actual parameter 4
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(202) : error C2065: 'true' : undeclared identifier
    c:\my documents\my programs\first windows app\first windows app\first windows app.c(211) : warning C4244: 'return' : conversion from 'WPARAM' to 'int', possible loss of data
    What is meant by "int differs in levels of indirection from 'void *'"? I'm confused about the 'void *' part (A void pointer? How can a pointer be void?) and what the statement means. There were as many as 58 errors originally but I've fixed those but the area with the boolean variable declaration and the 5 struct declarations are what's messing me up.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    There is no bool type in C.

    > (skipping the first one as it says fopen is deprecated)
    Yeah, that's just M$ trying to rewrite the libraries in their own image.
    There's a macro you can define to cause it to turn off all that 'deprecated by M$ crap'.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Math wizard
    Join Date
    Dec 2006
    Location
    USA
    Posts
    582
    You forgot about the case with the structs in the WinMain function. Read the build log and you'll see the errors, of which occur so many more times than any other error. The error with "too few arguments" is likely due to this. Why is it saying that "window_border is an undeclared identifier even though I have it declared in the WinMain function? The other errors I've fixed but what about the warnings?

  4. #4
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    in C you cannot mix declarations and statements

    move your variable declararations before other code
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  5. #5
    Math wizard
    Join Date
    Dec 2006
    Location
    USA
    Posts
    582
    Then this tutorial has a mistake in it. The tutorial's code shows a struct within a function with the declaration outside it. That tutorial has this as one of the samples:

    Code:
    struct database {
      int id_number;
      int age;
      float salary;
    };
    
    int main()
    {
      struct database employee;  /* There is now an employee variable that has
                                  modifiable variables inside it.*/
      employee.age = 22;
      employee.id_number = 1;
      employee.salary = 12000.21;
    }
    You can see this in the "C programming tutorials" section. It's the exact same set up I've got in my code above (only, instead of 1 struct and one creation of it, I have 5 creations for the same single struct). You may consider wanting to fix this particular lesson.

    The code now compiles, but I don't get the image to display. It should be easily noticed on the white background as the image is black with stars and colorful 3D text. Instead, it's all white, as if the image was all white.

  6. #6
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    this snipplet is ok

    problem is other place
    Code:
    int f(void)
    {
       int i = 0; //is OK
       i++; //OK
       int j; //not OK in C before C99 -  should be before i++
       //...
    }
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  7. #7
    Math wizard
    Join Date
    Dec 2006
    Location
    USA
    Posts
    582
    I see now. So what's wrong with the image displaying stuff? I cross checked the details with my hex edittor to make sure the header data was being read properly (in the right order), but no image is displayed at all. I made a few modifications to the code but neither the above version nor this one work. What's missing that I need, if anything?

    Code:
    void draw_test_image()
    {
    	img_handle = DrawDibOpen();
    	
    	file_handle = fopen("C:\\My Documents\\My programs\\ulillilliacity.bmp", "rb"); // read the source BMP file to display, binary mode
    	// fopen_s(file_handle, "C:\\My Documents\\My programs\\ulillilliacity.bmp", "rb"); // causes unexplained warning - 'FILE **' differs in levels of indirection from 'FILE *'
    	// fseek(file_handle, 2, seek_set); // skip the first two bytes, the file identifier, the string "BM"
    	// fill the bitmap file header struct reading from the file
    	fread(&bmp_filehead.bfType, 2, 1, file_handle); // bytes 00 and 01
    	fread(&bmp_filehead.bfSize, 4, 1, file_handle); // 02 through 05
    	fread(&bmp_filehead.bfReserved1, 2, 1, file_handle); // 06 and 07
    	fread(&bmp_filehead.bfReserved2, 2, 1, file_handle); // 08 and 09
    	fread(&bmp_filehead.bfOffBits, 4, 1, file_handle); // 0A through 0D
    	
    	// fill the bitmap info header struct reading from the file
    	fread(&bmp_head.biSize, 4, 1, file_handle); // bytes 0E through 11
    	fread(&bmp_head.biWidth, 4, 1, file_handle); // 12 through 15
    	fread(&bmp_head.biHeight, 4, 1, file_handle); // 16 through 19
    	fread(&bmp_head.biPlanes, 2, 1, file_handle); // 1A and 1B
    	fread(&bmp_head.biBitCount, 2, 1, file_handle); // 1C and 1D
    	fread(&bmp_head.biCompression, 4, 1, file_handle); // 1E through 21
    	fread(&bmp_head.biSizeImage, 4, 1, file_handle); // 22 through 25
    	fread(&bmp_head.biXPelsPerMeter, 4, 1, file_handle); // 26 through 29
    	fread(&bmp_head.biYPelsPerMeter, 4, 1, file_handle); // 2A through 2D
    	fread(&bmp_head.biClrUsed, 4, 1, file_handle); // 2E through 31
    	fread(&bmp_head.biClrImportant, 4, 1, file_handle); // 32 through 35
    	fread(&bmp_image, 1, bmp_head.biSizeImage, file_handle); // read the remainder of the bits, the image data part // bytes 36 and onward
    	fclose(file_handle);
    	
    	DrawDibDraw(img_handle, HDC_handle, window_size_base.x/2-bmp_head.biWidth/2, window_size_base.y/2-bmp_head.biHeight/2, bmp_head.biWidth, bmp_head.biHeight, bmp_head_pointer, bmp_image_pointer, 0, 0, bmp_head.biWidth, bmp_head.biHeight, 0); // center the full image in the window
    	DrawDibClose(img_handle); // free the resources
    	ReleaseDC(hwnd, HDC_handle); // free the DC handle
    }

  8. #8
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > // fopen_s(file_handle, "C:\\My Documents\\My programs\\ulillilliacity.bmp", "rb"); // causes
    Because it should have been &file_handle
    Which is what the error message was telling you.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  9. #9
    Math wizard
    Join Date
    Dec 2006
    Location
    USA
    Posts
    582
    I commented out that function as I'm not using it. I'm using the fopen version. Note how I have fopen_s commented out but not fopen. There are no compiler errors nor any errors/warnings with that part and the program runs. No image is displayed though.

  10. #10
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    you have ReleaseDC in your code, but where do you initialize HDC_handle?
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  11. #11
    Math wizard
    Join Date
    Dec 2006
    Location
    USA
    Posts
    582
    It's initialized in the WinMain function. It's shown in the first post of this thread, flagged in red below:

    Code:
    ...
    if (!hwnd)
    		return 0;
    	done = false; // initialize loop condition variable
    	/* main message loop */
    	
    	[color:#ff0000]HDC_handle = GetDC(hwnd);[/color]
    	
    	draw_test_image();
    	
    	while(!done)
    	{
    		PeekMessage(&msg,hwnd,NULL,NULL,PM_REMOVE);
    ...l
    Note that it's above the function being called that has the image display stuff in it and thus it's initialized before the image drawing code function is called. Normally, as far as I know, instructions are processed top to bottom as humans would read a book and when a function call is present, the instructions of that function are processed top to bottom then when the function is done, the function that called it continues on which then goes into the loop that causes 100% CPU usage making everything go slowly (the image drawing stuff is done before this loop even starts). I should try putting a pause of one second before that loop starts to see if the extreme CPU usage from that loop is causing problems. Fixing this is, at the moment, outside my knowledge as I don't know what this "message" stuff is.

    Edit: Never mind - I found the cause - the pointers for the bitmap data was not set for some reason. I did a little debug test combining sprintf() with the MessageBox function and found that the pointers for bmp_head_pointer and bmp_image_pointer were equal to zero, the null value, and thus pointing to nothing. I set the pointers and saw nonzero values and when I cleared my debug message box, the image displayed just as I expected it to. Now to move on to other tasks.... Thanks for the assistance.
    Last edited by ulillillia; 12-18-2006 at 05:26 AM. Reason: Issues resolved - pointers not set

Popular pages Recent additions subscribe to a feed