Skip to content

Instantly share code, notes, and snippets.

@PBfordev
PBfordev / listview_hittest.cpp
Last active March 30, 2022 12:23
Demonstrates an issue with ListView_HitTest() when the header is displayed.
/*********************************************************************************
Demonstrates that ListView_HitTest() doesn't account for the header.
If the mouse cursor is over the listview header and we translate the current
mouse cursor screen coordinates with ScreenToClient(hwndListView),
the listview reports:
* for the unscrolled view, hit on item 0,
* for the scrolled view, hit on an item above the top visible item.
@PBfordev
PBfordev / test-wxprocess-onterminate2.cpp
Last active October 27, 2021 20:35
Tests whether wxProcess::OnTerminate() is called when the process is killed
#include <wx/wx.h>
#include <wx/process.h>
class MyProcess : public wxProcess
{
public:
void OnTerminate(int pid, int status) override
{
wxLogMessage("MyProcess::OnTerminate(): pid = %d, status = %d", pid, status);
}
@PBfordev
PBfordev / test-wxprocess-onterminate.cpp
Created October 27, 2021 10:51
Tests whether wxProcess::OnTerminate() is called when the process is killed
#include <wx/wx.h>
#include <wx/process.h>
class MyProcess : public wxProcess
{
public:
void OnTerminate(int pid, int status) override
{
wxLogMessage("OnTerminate(): pid = %d, status = %d", pid, status);
}
@PBfordev
PBfordev / TestwxDesktopEnv.cpp
Created October 4, 2021 15:15
Simple program to test wxDesktopEnv
#include <wx/wx.h>
#include <wx/desktopenv.h>
class MyFrame : public wxFrame
{
public:
MyFrame() : wxFrame(nullptr, wxID_ANY, "RecycleBin restore Test")
{
wxPanel* mainPanel = new wxPanel(this);
wxBoxSizer* mainPanelSizer = new wxBoxSizer(wxVERTICAL);
#include <windows.h>
#include <tchar.h>
void FatalError(LPCTSTR errorMessage)
{
MessageBox(NULL, errorMessage, _T("Fatal error"), MB_OK | MB_ICONERROR);
exit(-1);
}
void Paint(HWND hWnd)
@PBfordev
PBfordev / webview_ege-focus.cpp
Created July 25, 2021 08:08
Demonstrates focus issues with wxWebViewEdge
#include <wx/wx.h>
#include <wx/webview.h>
const char* HTMLSource =
R"(<!DOCTYPE html>
<html>
<body>
<h1>Log In</h1>
#include <wx/wx.h>
#include <wx/artprov.h>
#include <wx/scrolwin.h>
class MyFrame: public wxFrame
{
public:
MyFrame() : wxFrame (nullptr, wxID_ANY, "Test")
{
wxSizer* scrolledSizer = new wxBoxSizer(wxVERTICAL);
@PBfordev
PBfordev / pushbuttons.cpp
Last active December 11, 2020 09:48
Shows enabled and disabled Win32 push buttons
#pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#include <windows.h>
#include <windowsx.h>
#include <tchar.h>
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if ( message == WM_DESTROY )
{
#include <wx/wx.h>
#include <wx/datectrl.h>
#ifdef __WXMSW__
#include <wx/msw/wrapcctl.h>
#endif;
// wxDatePickerNoToday is a wxDatePickerCtrl with wxDP_DROPDOWN style
// which on MSW does not display the today circle and today date
// in the drop down calendar
#include <wx/wx.h>
#include <wx/artprov.h>
class MyApp : public wxApp
{
public:
bool OnInit() override
{
wxFrame* f = new wxFrame(nullptr, wxID_ANY, "Toolbar test");
wxPanel* p = new wxPanel(f);