Thread: I can't work out these errors

  1. #1
    Registered User
    Join Date
    Aug 2002

    I can't work out these errors

    Here is my code:

    #include <windows.h>
    #include <tchar.h>
    #include <math.h>
    #include <stdio.h>
    #include "resource.h"
    BOOL GetBitmapFileName(TCHAR *filename, int len, HWND hWnd)
    	ZeroMemory(&ofn, sizeof(OPENFILENAME));
    	ofn.lStructSize = sizeof(OPENFILENAME);
    	ofn.hwndOwner = hWnd;
    	ofn.lpstrFilter = _T("Bitmap Files (*.bmp)\0*.bmp\0All Files (*.*)\0*.*\0\0");
    	ofn.lpstrFile = filename;
    	ofn.nMaxFile = len;
    	ofn.lpstrTitle = _T("Browse");
    	return GetOpenFileName(&ofn);
    HBITMAP LoadBitmapFile(const TCHAR *filename)
    	return (HBITMAP)LoadImage(NULL, filename, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
    BOOL MainDialog_OnCommand(HWND hWnd, WORD wCommand, WORD wNotify, HWND hControl);
    BOOL MainDialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    	HDC		hDC;
    	switch (uMsg)
    	case WM_COMMAND:
    		return MainDialog_OnCommand(hWnd, LOWORD(wParam),
    			HIWORD(wParam), (HWND)lParam);
    	case WM_PAINT:
    		hDC = BeginPaint(hWnd, &ps);
    		MainDialog_OnPaint(hWnd, hDC);
    		EndPaint(hWnd, &ps);
    		return TRUE;
    	case WM_CLOSE:
    		EndDialog(hWnd, 0);
    		return TRUE;
    	return FALSE;
    TCHAR	szBitmapFilename[_MAX_PATH];
    HBITMAP	hBitmap;
    BOOL MainDialog_OnCommand(HWND hWnd, WORD wCommand, WORD wNotify, HWND hControl)
    	switch (wCommand)
    	case IDC_BROWSE:
    		if (GetBitmapFileName(szBitmapFilename,
    			sizeof(szBitmapFilename) / sizeof(TCHAR), hWnd))
    			SetDlgItemText(hWnd, IDC_FILENAME, szBitmapFilename);
    		// fall through into OK handler
    	case IDOK:
    		if (hBitmap != NULL)
    		GetDlgItemText(hWnd, IDC_FILENAME, szBitmapFilename,
    			sizeof(szBitmapFilename) / sizeof(TCHAR));
    		hBitmap = LoadBitmapFile(szBitmapFilename);
    		RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE);
    	case IDCANCEL:
    		EndDialog(hWnd, wCommand);
    	return TRUE;
    void MainDialog_OnPaint(HWND hWnd, HDC hDC)
    	if (hBitmap == NULL)
    	RECT	r;
    	POINT	p;
    	GetClientRect(GetDlgItem(hWnd, IDC_VIEW), &r);
    	p.x = r.left;
    	p.y =;
    	ClientToScreen(GetDlgItem(hWnd, IDC_VIEW), &p);
    	ScreenToClient(hWnd, &p);
    	DrawState(hDC, NULL, NULL, (LPARAM)hBitmap, 0, p.x, p.y, 0, 0, DST_BITMAP | DSS_NORMAL);
    int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hinstPrev, LPSTR lpCmdLine, int nCmdShow)
    	DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_DIALOG1),
    		NULL, (DLGPROC)MainDialogProc, 0);
    	return 0;
    When I go to compile this with my code it comes back with two errors can someone please help me solve them:

    bmpviewer.c: 44 missing prototype for MainDialog_OnPaint

    bmpviewer.c: 88 declaration of 'MainDialog_OnPaint' does not match previous declaration at bmpviewer.c 44

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Try adding a function declaration to the top of your code ala;

    void MainDialog_OnPaint(HWND hWnd, HDC hDC);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with some errors in my game
    By Mikalio in forum C Programming
    Replies: 4
    Last Post: 12-04-2008, 03:16 PM
  2. Replies: 3
    Last Post: 11-17-2008, 12:36 PM
  3. How properly inherit from template?
    By 6tr6tr in forum C++ Programming
    Replies: 118
    Last Post: 04-25-2008, 05:30 AM
  4. executing errors
    By s0ul2squeeze in forum C++ Programming
    Replies: 3
    Last Post: 03-26-2002, 01:43 PM
Website Security Test