Skip to content

Instantly share code, notes, and snippets.

@PBfordev
PBfordev / test.html
Created April 25, 2020 20:15
Needed for js-to-wx.cpp gist
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<meta charset="UTF-8">
</head>
<body>
<h1>Title H1</h1>
<p>Right click or double click inside the document to trigger a response inside wxWidgets C++ code.</p>
@PBfordev
PBfordev / js-to-wx.cpp
Last active April 25, 2020 20:27
Demonstrates communication from javascript inside wxWebView to wxWidgets C++ code
#include <wx/wx.h>
#include <wx/filename.h>
#include <wx/stdpaths.h>
#include <wx/uri.h>
#include <wx/webview.h>
#if defined(__WXMSW__)
#include <wx/msw/webview_ie.h>
#endif //#if defined(__WXMSW__)
#include <map>
#include <wx/wx.h>
#include <wx/choicdlg.h>
#include <wx/dirdlg.h>
#include <wx/dynlib.h>
#include <wx/msw/private/comptr.h>
#include <wx/msw/wrapwin.h>
#include <wx/msw/wrapshl.h>
#include <initguid.h>
@PBfordev
PBfordev / wxcontrolsizes.cpp
Created November 2, 2019 19:29
Shows dimensions of many wxWidgets common controls in pixels and dips, automatically updated when DPI changes.
// Shows dimensions of many wxWidgets common controls
// in pixels and dips, automatically updated when DPI changes.
// MSW only, wxWidgets 3.1.3+ only
#include <wx/wx.h>
#include <wx/activityindicator.h>
#include <wx/artprov.h>
#include <wx/bmpbuttn.h>
#include <wx/commandlinkbutton.h>
@PBfordev
PBfordev / sizer_borders_pmv2.cpp
Last active October 29, 2019 20:59
Demonstrates sizer borders in a PMv2 application
#include <wx/wx.h>
class MyFrame : public wxFrame
{
public:
MyFrame() : wxFrame(NULL, wxID_ANY, _("Test"), wxDefaultPosition, wxSize(800, 600))
{
wxSizer* mainSizer = new wxBoxSizer(wxVERTICAL);
mainSizer->Add(new wxButton(this, wxID_OK), wxSizerFlags().Expand().TripleBorder());
#include <wx/wx.h>
#include <wx/artprov.h>
#include <wx/bmpbuttn.h>
#include <wx/commandlinkbutton.h>
class MyDialog : public wxDialog
{
public:
MyDialog() : wxDialog(NULL, wxID_ANY, "Test", wxDefaultPosition, wxSize(1024, 800))
#include <wx/wx.h>
#include <wx/msw/wrapshl.h>
bool MoveToRecycleBin(const wxString& path)
{
bool result = false;
SHFILEOPSTRUCT fileOp;
const wxString temp = path + '\0';
::ZeroMemory(&fileOp, sizeof(fileOp));
@PBfordev
PBfordev / win32scrollbar.cpp
Created June 6, 2019 15:06
Implementation with pure Win32
#ifdef _MSC_VER
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif
#define NOMINMAX
#include <windows.h>
#include <windowsx.h>
#include <tchar.h>
#include <wx/wx.h>
class MyFrame : public wxFrame
{
public:
MyFrame() : wxFrame(nullptr, wxID_ANY, "wxWidgets ScrollBar Test", wxDefaultPosition, wxSize(800, 600))
{
wxBoxSizer* mainSizer = new wxBoxSizer(wxHORIZONTAL);
m_scrollBar = new wxScrollBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSB_VERTICAL);
@PBfordev
PBfordev / wxImageCanvas2.cpp
Created August 20, 2018 17:48
wxImageCanvas2
#include <wx/wx.h>
#include <wx/scrolwin.h>
#include <wx/dcbuffer.h>
#include <wx/filedlg.h>
#include <wx/filename.h>
class ImageCanvas : public wxScrolledCanvas
{
public:
ImageCanvas(wxWindow* parent)