Entries tagged wxWidgets

[wxWidgets] Compiling wxWidgets for MS Windows

Posted on Dec 30, 2014

1. Get the latest source code from https://www.wxwidgets.org/downloads/ (ver 3.0.2 as of Dec 30, 2014) and unzip it somewhere.

2. Go to ./build/msw

3. Compile
– For MS Visual Studio, find a solution file for your VS version (e.g., wx_vc12.sln) and build.
– For MinGW, open a cmd window and set the bin folder of MinGW in the beginning of your PATH environment variable, like the following example.

set "PATH = C:\GNU\mingw64\bin;%path%"

Then, run the following commands, depending on the version you want to build.

@ release DLL
mkdir ..\..\lib\gcc_dll\mswu\wx
mingw32-make -f makefile.gcc CXXFLAGS="-std=gnu++11" BUILD=release SHARED=1 UNICODE=1 MSLU=0 clean
mingw32-make -f makefile.gcc CXXFLAGS="-std=gnu++11" BUILD=release SHARED=1 UNICODE=1 MSLU=0

@ debug DLL
mkdir ..\..\lib\gcc_dll\mswud\wx
mingw32-make -f makefile.gcc CXXFLAGS="-std=gnu++11" BUILD=debug SHARED=1 UNICODE=1 MSLU=0 clean
mingw32-make -f makefile.gcc CXXFLAGS="-std=gnu++11" BUILD=debug SHARED=1 UNICODE=1 MSLU=0

@ release static LIB
mkdir ..\..\lib\gcc_lib\mswu\wx
mingw32-make -f makefile.gcc CXXFLAGS="-std=gnu++11" BUILD=release SHARED=0 UNICODE=1 MSLU=0 clean
mingw32-make -f makefile.gcc CXXFLAGS="-std=gnu++11" BUILD=release SHARED=0 UNICODE=1 MSLU=0

@ debug static LIB
mkdir ..\..\lib\gcc_lib\mswud\wx
mingw32-make -f makefile.gcc CXXFLAGS="-std=gnu++11" BUILD=debug SHARED=0 UNICODE=1 MSLU=0 clean
mingw32-make -f makefile.gcc CXXFLAGS="-std=gnu++11" BUILD=debug SHARED=0 UNICODE=1 MSLU=0

Continue…

[wxWidgets] Add an icon from .ico file

Posted on Dec 21, 2014

YourApp.rc

mondrian ICON "mondrian.ico" // identifier ICON filename

#include "wx/msw/wx.rc"

YourApp.cpp

// In the constructor,
MyDialog::MyDialog(wxWindow* parent)
{
	...

	SetIcon(wxICON(mondrian)); // the same identifier that you put in the rc file
}

[wxWidgets] Add “About…” to the system menu

Posted on Dec 21, 2014

Original post: https://forums.wxwidgets.org/viewtopic.php?f=20&t=13921

MyDialog.h

class MyDialog : public wxDialog
{
	...

	// Override MSWTranslateMessage
	bool MSWTranslateMessage(WXMSG* pMsg);
};

MyDialog.cpp

// Include aboutdlg.h
#include <wx/aboutdlg.h>

MyDialog::MyDialog(wxWindow* parent)
{
	...

	// Add the menu item, "About...", to the system menu
	HMENU hSystemMenu = ::GetSystemMenu((HWND__*)GetHWND(), FALSE);
	::AppendMenu(hSystemMenu, MF_SEPARATOR, 0, wxT(""));
	::AppendMenu(hSystemMenu, MF_STRING, wxID_ABOUT, wxT("About..."));
	::DrawMenuBar((HWND__*)GetHWND());
}

// implement the message handler
bool MyDialog::MSWTranslateMessage(WXMSG* pMsg)
{
	if (WM_SYSCOMMAND==pMsg->message && wxID_ABOUT==pMsg->wParam)
	{
		wxAboutDialogInfo di;
		di.SetName(wxT("My App"));
		di.SetVersion(wxT("1.00"));
		di.SetDescription(wxT("This app does cool trix!"));

		wxAboutBox(di);

		return true; // Message processed
	}

	return wxDialog::MSWTranslateMessage(pMsg);
}