Thread: Refreshing an image

  1. #1
    george7378
    Guest

    Refreshing an image

    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.

  2. #2
    Registered User
    Join Date
    Jun 2010
    Posts
    4
    Hello

    When you compile the app, the compiler reads the image and then compiles the image INTO THE EXE FILE, so the program doesn't actually read your bmp file at all. It simply reads its internal resources. If you want to use an external file, you need to load it using some code in the app (C++), rather than by compiling it into the resources file.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. merge multiple image file into one image
    By mr_empty in forum C++ Programming
    Replies: 7
    Last Post: 12-09-2009, 02:12 PM
  2. Problem reading tiff image files?
    By compz in forum C++ Programming
    Replies: 9
    Last Post: 10-30-2009, 04:17 AM
  3. Replies: 1
    Last Post: 05-27-2009, 12:46 PM
  4. Simple Image Processing
    By ejohns85 in forum C++ Programming
    Replies: 4
    Last Post: 03-19-2009, 12:10 PM
  5. Replies: 4
    Last Post: 03-02-2003, 09:12 AM