Oh, I'm halfway there.....
Oh, I'm halfway there.....
Okay, I'm halfway there! I'm running on Windows 10 - 64 bit system. I've finally managed to compile thw wxWidgets library from source for 64-bit code. BUT I have not been able to get it to work generating 32-bit code. Help!
Moving on, how can I load an icon from an icone file?
Moving on, how can I load an icon from an icone file?
Re: Oh, I'm halfway there.....
Compiler, IDE? If you were using the command line, which command did you use?
By using the appropriate constructor: https://docs.wxwidgets.org/trunk/classw ... b724ae0543Moving on, how can I load an icon from an icone file?
Use the source, Luke!
Re: Oh, I'm halfway there.....
With all due respect sir, I asked how to do something. I don't need you to tell me just to look at the documentation. I've already looked at the documentation! Unfortunately, there is a major flaw within the documentation - as good as it is, they don't show you an example of how to properly use the functions! I've tried it unsuccessfully. Looking at the documentation doesn't show me what or how to do it!
Re: Oh, I'm halfway there.....
On the other topic, I'm using Red Panda Dev C++ w/MinGW GCC 11.2.0 64-Bit, and Embarcadero Dev C++6.3 w/TDM GCC 10.3.0 64-Bit IDEs.
As I said, 64 bit compiles and runs without any issues. Compiling for 32 bit won't work.
As I said, 64 bit compiles and runs without any issues. Compiling for 32 bit won't work.
Re: Oh, I'm halfway there.....
Hi,
What command did you use to build 32-bit library?
Thank you.
What command did you use to build 32-bit library?
Thank you.
Re: Oh, I'm halfway there.....
Hi,
And for you icon issue - please show how exactly did you tried it?
Thank you.
And for you icon issue - please show how exactly did you tried it?
Thank you.
Re: Oh, I'm halfway there.....
//cMain.cpp
cMain::cMain() : wxMDIParentFrame(nullptr, wxID_ANY, "Minimal Application", wxPoint(30, 30), wxSize(900, 600))
{
// Set the frame icon
wxBitmap *icon = new wxBitmap();
icon->LoadFile("STL22.ico");
// Create a menu bar
wxMenu *fileMenu = new wxMenu;
// The "About" item should be in the help menu
wxMenu *helpMenu = new wxMenu;
helpMenu->Append(wxID_ABOUT, wxT("&About...\tF1"),wxT("Show about dialog"));
fileMenu->Append(wxID_EXIT, wxT("E&xit\tAlt-X"),wxT("Quit this program"));
// Now append the freshly created menu to the menu bar...
wxMenuBar *menuBar = new wxMenuBar();
menuBar->Append(fileMenu, wxT("&File"));
menuBar->Append(helpMenu, wxT("&Help"));
// ... and attach this menu bar to the frame
SetMenuBar(menuBar);
// Create a status bar just for fun
CreateStatusBar(2);
SetStatusText("Welcome to wxWidgets!");
}
cMain::cMain() : wxMDIParentFrame(nullptr, wxID_ANY, "Minimal Application", wxPoint(30, 30), wxSize(900, 600))
{
// Set the frame icon
wxBitmap *icon = new wxBitmap();
icon->LoadFile("STL22.ico");
// Create a menu bar
wxMenu *fileMenu = new wxMenu;
// The "About" item should be in the help menu
wxMenu *helpMenu = new wxMenu;
helpMenu->Append(wxID_ABOUT, wxT("&About...\tF1"),wxT("Show about dialog"));
fileMenu->Append(wxID_EXIT, wxT("E&xit\tAlt-X"),wxT("Quit this program"));
// Now append the freshly created menu to the menu bar...
wxMenuBar *menuBar = new wxMenuBar();
menuBar->Append(fileMenu, wxT("&File"));
menuBar->Append(helpMenu, wxT("&Help"));
// ... and attach this menu bar to the frame
SetMenuBar(menuBar);
// Create a status bar just for fun
CreateStatusBar(2);
SetStatusText("Welcome to wxWidgets!");
}
Re: Oh, I'm halfway there.....
Hi,
What happen when you use this code?
Also - I don't see an "icon" variable being used anywhere after the call to LoadIcon()...
Thank you.
What happen when you use this code?
Also - I don't see an "icon" variable being used anywhere after the call to LoadIcon()...
Thank you.
Re: Oh, I'm halfway there.....
I compiled the library via batch file buildgcc_d_r.bat:
echo off
cls
mingw32-make -fmakefile.gcc clean
mingw32-make -fmakefile.gcc BUILD=debug CFG=-m32 UNICODE=0
mingw32-make -fmakefile.gcc BUILD=release CFG=-m32 UNICODE=0
:done
echo off
cls
mingw32-make -fmakefile.gcc clean
mingw32-make -fmakefile.gcc BUILD=debug CFG=-m32 UNICODE=0
mingw32-make -fmakefile.gcc BUILD=release CFG=-m32 UNICODE=0
:done
Re: Oh, I'm halfway there.....
Code: Select all
wxTopLevelWindow::SetIcon( const wxIcon &icon )
Code: Select all
mingw32-make -fmakefile.gcc clean
mingw32-make -fmakefile.gcc BUILD=debug CFG=-m32 UNICODE=0
mingw32-make -fmakefile.gcc BUILD=release CFG=-m32 UNICODE=0
Use the source, Luke!
Re: Oh, I'm halfway there.....
"What happen when you use this code?"
A message box: "Minimal Error" , Can't load bitmap 'STL22.ico' from resources. Check .rc file.
A message box: "Minimal Error" , Can't load bitmap 'STL22.ico' from resources. Check .rc file.
Re: Oh, I'm halfway there.....
On the icon issue...
Now that you've told me what I'm not doing, how about showing me what I should be doing with a code example???
Now that you've told me what I'm not doing, how about showing me what I should be doing with a code example???
Re: Oh, I'm halfway there.....
Hi,
What is inside your rc file?
Thank you.
What is inside your rc file?
Thank you.
Re: Oh, I'm halfway there.....
Your code seems compilant, but there seems to be an issue with your building process.
Apparently, you are trying to link a 64-bit resource file into a 32-bit application, but it cannot work since the formats are incompatible. (Or you simply do not have a resource file?)
First, I do not use TDM compiler since it creates binaries that are incompatible with most of my dependencies, so instead I'm using the MSVCRT-based WinLibs MinGW-w64 GCC compiler – most recent binaries GCC 12.2.0 (64-bit ; 32-bit). [or GCC 12.2.0 UCRT (64-bit ; 32-bit) if you are linking with UCRT]
What works for me is creating the resource files (`icon.res` and `icon_x64.res`) using the 32-bit and 64-bit compiler versions, respectively, by commands
(e.g. via `.bat` file) with `icon.rc` being in the same directory as your `icon.ico` and containingset GCC_HOME_32=<path to `mingw32` directory of 32-bit GCC>
set GCC_HOME_64=<path to `mingw64` directory of 64-bit GCC>
set WX_HOME=<path to `wxWidgets` directory>
%GCC_HOME_32%/bin/windres icon.rc -O coff -I%WX_HOME%/include -o icon.res
%GCC_HOME_64%/bin/windres icon.rc -O coff -I%WX_HOME%/include -o icon_x64.res --target=pe-x86-64
and then when linking usingaaaa_icon ICON "icon.ico"
#include <wx/msw/wx.rc>
or%GCC_HOME_32%/bin/g++ -o <name>.exe "<relative path to icons>/icon.res" <all other linker arguments>
depending on the targeted CPU bus width.%GCC_HOME_64%/bin/g++ -o <name>.exe "<relative path to icons>/icon_x64.res" <all other linker arguments>
If you want your code to set your icon to the frame, you should then also replace
Code: Select all
wxBitmap *icon = new wxBitmap();
icon->LoadFile("STL22.ico");
Code: Select all
SetIcon(wxICON(aaaa_icon));