CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Threaded View

  1. #1
    george7378 Guest

    Images and dialog boxes

    Hi everyone,

    I have the following code which displays an image in a picture frame on a dialog box:

    Code:
    #include "windows.h"
    #include <cstdio>
    #include "resource.h" 
    #include <tchar.h>
    #include <urlmon.h>
    #include <iostream>
    #include "stdlib.h"
    
    #pragma comment(lib, "urlmon.lib")
    
    BOOL CALLBACK ToolDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
    {
    	switch(Message)
    	{
    		case WM_COMMAND:
    			switch(LOWORD(wParam))
    			{
    				case IDC_SUN:
    					DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_SUNPAGE), hwnd, ToolDlgProc);
    				break;
    							
    				case IDC_CLOSEASTRO:
    					EndDialog(hwnd, 0);
    				break;
    				
    				case IDC_MOON:
    					break;
    
    				case IDC_ABOUT:
                        DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_ABOUT), hwnd, ToolDlgProc);
    			    break;
    
    				case IDC_ABOUTOK:
    					EndDialog(hwnd, 0);
    				break;
    
    				case IDC_STARTLOAD:
    					EndDialog(hwnd, 0);
    					DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_MAIN), hwnd, ToolDlgProc);
    				break;
    
    			}
    		break;
    
    		case WM_CLOSE:
    			EndDialog(hwnd, 0);
    		    break;
    
    		default:
    			return FALSE;
    	}
    	return TRUE;
    }
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    	LPSTR lpCmdLine, int nCmdShow)
    {
    	return DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAIN), NULL, ToolDlgProc);
    }
    Here is the resource file:

    Code:
    LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
    IDB_SUNPIC        BITMAP DISCARDABLE         "C:\\Documents and Settings\\XP\\My Documents\\latest.bmp"
    
    IDD_SUNPAGE DIALOG 0, 0, 490, 352
    STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_FIXEDSYS | WS_VISIBLE | WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_POPUP | WS_SYSMENU
    CAPTION "Latest Sun"
    FONT 8, "Ms Shell Dlg 2"
    {
        CONTROL         IDB_SUNPIC, IDC_SUNFRAME, WC_STATIC, SS_BITMAP, 30, 12, 341, 236
    }
    I have created the bitmap and picture frame resources in the RC file, and assigned the bitmap to the frame in the above line. When I run the program, the image displays, but if I change the image and restart the program, it stays the same when the program displays it. How do I make it refresh the image?

    Thanks.
    Last edited by george7378; June 24th, 2010 at 10:10 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured