wxFileName::GetTempDir(); wxWidgets
Create cross-platform applications with native look and feel for Win32, Mac OS X, GTK+, X11, Motif, WinCE, and more using one codebase.
How to get the path of temporary folder or create a temporary file?
How to start application automatically with windows startup?
if (bAutoStart)
{
#ifdef __WXMSW__
wxRegKey *pRegKey = new wxRegKey(
wxT("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run")
);
// will create the Key if it does not exist
if( !pRegKey->Exists() )
pRegKey->Create();
// GetExecutablePath() is a user defined function, that returns this executable path.
pRegKey->SetValue(wxApp::GetAppName(), wxStandardPaths().GetExecutablePath());
delete pRegKey;
#endif
}
else
{
#ifdef __WXMSW__
wxRegKey *pRegKey = new wxRegKey(
{
#ifdef __WXMSW__
wxRegKey *pRegKey = new wxRegKey(
wxT("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run")
);
// will create the Key if it does not exist
if( !pRegKey->Exists() )
pRegKey->Create();
// GetExecutablePath() is a user defined function, that returns this executable path.
pRegKey->SetValue(wxApp::GetAppName(), wxStandardPaths().GetExecutablePath());
delete pRegKey;
#endif
}
else
{
#ifdef __WXMSW__
wxRegKey *pRegKey = new wxRegKey(
How to get the path of executable/process?
Check the newer API in wxWidgets 2.8: wxStandardPaths::GetExecutablePath.
How to get the size of the desktop screen?
wxSystemSettings::GetMetric(wxSYS_SCREEN_X);
wxSystemSettings::GetMetric(wxSYS_SCREEN_Y);
wxSystemSettings::GetMetric(wxSYS_SCREEN_Y);
::wxDisplaySize(&width, &height);
also the functions that can be of interest are:
wxSystemSettings::GetScreenType();
wxDisplay::GetGeometry();
wxDisplay::GetClientArea();
wxDisplay::GetGeometry();
wxDisplay::GetClientArea();
How to display balloon tooltips in wxTaskBarIcon?
Download and install the patch written by lowjoel. Open the adv project''s settings from the wxWidgets visual studio solution and add _WIN32_IE=0x0600 to the Preprocessor Definitions in the C/C++ section for all configurations, then recompile the adv project. This will add a new function ShowBalloon to the wxTaskBarIcon class.
How to create a non-rectangular window?
You can see the ''shaped'' sample in the samples directory of wxWidgets installation.
wxRegion region(wxBitmap(wxT("star.png"), wxBITMAP_TYPE_PNG), *wxWHITE);
SetShape(region);
SetShape(region);
You have to create a wxRegion object using an image and a mask color and calling SetShape method of wxTopLevelWindow to change the windows shape, also when creating the shaped frame you have to use the wxFRAME_SHAPED flag in the wxFrame constructor.
How to add "About..." menu item in system menu or handle windows specific events?
In the dialog wxInitDialogEvent event handler function or the wxFrame constructor add the following lines:
In the dialog or frame header file add the following unused identifier for IDM_ABOUT:
// Add about option to system menu
HMENU hSystemMenu = ::GetSystemMenu(GetHwnd(),FALSE);
::AppendMenu(hSystemMenu,MF_SEPARATOR,0,wxT(""));
::AppendMenu(hSystemMenu,MF_STRING,IDM_ABOUT,wxT("About..."));
::DrawMenuBar(GetHwnd());
HMENU hSystemMenu = ::GetSystemMenu(GetHwnd(),FALSE);
::AppendMenu(hSystemMenu,MF_SEPARATOR,0,wxT(""));
::AppendMenu(hSystemMenu,MF_STRING,IDM_ABOUT,wxT("About..."));
::DrawMenuBar(GetHwnd());
#define IDM_ABOUT wxID_HIGHEST // System menu "About..." ID
How to retrieve the state of a key?
bool wxGetKeyState(wxKeyCode key)
For normal keys, returns true if the specified key is currently down. For togglable keys (Caps Lock, Num Lock and Scroll Lock), returns true if the key is toggled such that its LED indicator is lit. There is currently no way to test whether togglable keys are up or down. Even though there are virtual key codes defined for mouse buttons, they cannot be used with this function currently.
To retrieve the state of all the virtual keys on windows use the Win32 API:
How to remove the focus rectangle from the bitmap button?
The wxBitmapButton by default uses the wxBU_AUTODRAW style flag, remove this flag and pass 0 instead of this flag. This will remove the focus rectangle from the bitmap button when selected.
How to launch a URL with the default browser?
wxLaunchDefaultBrowser(strURL);