Is there a way to load an icon from a memory file handler?

Posted by Jon Trauntvein on Stack Overflow See other posts from Stack Overflow or by Jon Trauntvein
Published on 2010-12-22T21:09:37Z Indexed on 2010/12/22 22:54 UTC
Read the original article Hit count: 239

Filed under:
|
|

I am writing wxWidgets application where I am importing the .ICO file as a header. I am attempting to use a wxMemoryFSHandler to make this icon (and others as well) accessible as files. I am using the following code to do this:

wxFileSystem::AddHandler(new wxMemoryFSHandler);
wxMemoryFSHandler::AddFileWithMimeType(
   "app_inactive.ico",
   CsiWebAdmin_ico,
   sizeof(CsiWebAdmin_ico),
   "image/vnd.microsoft.icon");

Unfortunately, if I try to load an icon from this "file" as shown below, it does not work. As I stepped through the MSW source (wx 2.8.10), I can see that the loader never attempted to resolve the virtual file name.

wxIcon icon("memory:app_inactive.ico");

I have also tried the following:

wxIcon icon(wxIconLocation("memory:app_inactive.ico"));

and have encountered the same results.

I realise that I can use resources to load these files but I would still face the same dilemma when the time came to port my application to GTK. Is there something obvious that I am missing?

© Stack Overflow or respective owner

Related posts about c++

Related posts about Icons