I can't work out these errors

This is a discussion on I can't work out these errors within the Windows Programming forums, part of the Platform Specific Boards category; Here is my code: Code: #include <windows.h> #include <tchar.h> #include <math.h> #include <stdio.h> #include "resource.h" BOOL GetBitmapFileName(TCHAR *filename, int len, ...

  1. #1
    Registered User
    Join Date
    Aug 2002
    Posts
    109

    I can't work out these errors

    Here is my code:

    Code:
    #include <windows.h>
    #include <tchar.h>
    #include <math.h>
    #include <stdio.h>
    #include "resource.h"
    
    BOOL GetBitmapFileName(TCHAR *filename, int len, HWND hWnd)
    {
    	OPENFILENAME	ofn;
    
    	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");
    	ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
    	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)
    {
    	PAINTSTRUCT	ps;
    	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)
    			DeleteObject(hBitmap);
    		GetDlgItemText(hWnd, IDC_FILENAME, szBitmapFilename,
    			sizeof(szBitmapFilename) / sizeof(TCHAR));
    		hBitmap = LoadBitmapFile(szBitmapFilename);
    		RedrawWindow(hWnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE);
    		break;
    
    	case IDCANCEL:
    		EndDialog(hWnd, wCommand);
    		break;
    	}
    	return TRUE;
    }
    
    void MainDialog_OnPaint(HWND hWnd, HDC hDC)
    {
    	if (hBitmap == NULL)
    		return;
    
    	RECT	r;
    	POINT	p;
    
    	GetClientRect(GetDlgItem(hWnd, IDC_VIEW), &r);
    	p.x = r.left;
    	p.y = r.top;
    	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
    Posts
    5,789
    Try adding a function declaration to the top of your code ala;

    Code:
    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, 02:16 PM
  2. Replies: 3
    Last Post: 11-17-2008, 11:36 AM
  3. How properly inherit from template?
    By 6tr6tr in forum C++ Programming
    Replies: 118
    Last Post: 04-25-2008, 04:30 AM
  4. executing errors
    By s0ul2squeeze in forum C++ Programming
    Replies: 3
    Last Post: 03-26-2002, 12:43 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21