Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Reload the MFC UI with different resources?

KnoenKnoen Member Posts: 1
I have an MFC application (MDI) that at startup loads a separate resource-dll containing dialogs, string table, menus, bitmaps etc. depending on the current language (which is set in a .ini-file).

My problem occurs when I want to change resource-dll during run-time (i do this from a new dialog). All new dialogs that opens after I load the new dll get the right language but stuff like the menus etc. keeps the old language. What I'm looking for is like a global redraw-function that completely reloads the UI from current resources.

I have tried UpdateWindow(), RedrawWindow(), and Invalidate() on the main window but nothing works.

Any ideas?

Comments

  • BitByBit_ThorBitByBit_Thor Member Posts: 2,444
    : I have an MFC application (MDI) that at startup loads a separate
    : resource-dll containing dialogs, string table, menus, bitmaps etc.
    : depending on the current language (which is set in a .ini-file).
    :
    : My problem occurs when I want to change resource-dll during run-time
    : (i do this from a new dialog). All new dialogs that opens after I
    : load the new dll get the right language but stuff like the menus
    : etc. keeps the old language. What I'm looking for is like a global
    : redraw-function that completely reloads the UI from current
    : resources.
    :
    : I have tried UpdateWindow(), RedrawWindow(), and Invalidate() on the
    : main window but nothing works.
    :
    : Any ideas?

    The resources are automatically applied when the windows are created. So reloading your entire application could be an option, but a sloppy one (I don't like it).

    I'm not so good at MFC, so there might (and I think: 'should') be an easier way to do this, but the solution I can come up with is writing a function to reset the window captions to their correct resource string.

    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
  • LundinLundin Member Posts: 3,711
    No idea what funny things VC++ does, but if you write a normal Windows program, you load the DLL dynamically in runtime (therefore "Dynamic Link Library"), and then use LoadBitmap() or whatever resource you want to load from it. If you use the following steps, it will work (pseudo code):

    [code]
    HINSTANCE hDLL = LoadLibrary(some_DLL);
    HBITMAP hbitmap = LoadBitmap(hDLL, "BITMAP_RESOURCE_NAME");

    WM_PAINT: (or similar event in RAD tool)
    SelectObject(hdc, hbitmap);
    BitBlt()

    ...

    if(I_want_to_change_DLL)
    {
    DeleteObject(hbitmap);
    FreeLibrary(some_DLL);
    hDLL = LoadLibrary(some_other_DLL);
    hbitmap = LoadBitmap(hDLL, "BITMAP_RESOURCE_NAME");
    }

    ...

    DeleteObject(hbitmap);
    FreeLibrary(some_DLL);
    [/code]
Sign In or Register to comment.