1 #include "stdafx.h"
2
3 #include <vector>
4
6
7 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 8 // Windows Header Files:
9 #include <windows.h>
10
12
14 HINSTANCE hPrevInstance,
15 LPWSTR lpCmdLine,
16 int nCmdShow)
17 {
19 UNREFERENCED_PARAMETER(hPrevInstance);
20 UNREFERENCED_PARAMETER(lpCmdLine);
21 UNREFERENCED_PARAMETER(nCmdShow);
22
23 OleInitialize(0); // for system drag-n-drop
24
25 // comment this out if you need system theming
27
28 auto message_pump = []() -> int {
29 MSG msg;
30 // Main message loop:
31 while (GetMessage(&msg, NULL, 0, 0))
32 {
33 TranslateMessage(&msg);
34 DispatchMessage(&msg);
35 }
36 return (int) msg.wParam;
37 };
38
39 int r =
uimain(message_pump);
40
41 OleUninitialize();
42
43 return r;
44
45 }
46
48
49 namespace application
50 {
51 const std::vector<sciter::string>&
argv() {
52 static std::vector<sciter::string> _argv;
53 if( _argv.size() == 0 ) {
54 int argc = 0;
55 LPWSTR *arglist = CommandLineToArgvW(GetCommandLineW(), &argc);
56 if( !arglist )
57 return _argv;
58 for( int i = 0; i < argc; ++i)
59 _argv.push_back(arglist[i]);
60 LocalFree(arglist);
61 }
62 return _argv;
63 }
64
67 }
68 }
69
70 bool window::load( aux::bytes utf8_html,
const WCHAR* base_url)
71 {
72 return FALSE !=
::SciterLoadHtml(_hwnd,utf8_html.start,utf8_html.length, base_url);
73 }
74 bool window::load( aux::chars utf8_html,
const WCHAR* base_url)
75 {
77 }
79 {
81 }
82
83 LRESULT window::on_message( HWINDOW hwnd, UINT msg, WPARAM wParam, LPARAM lParam, BOOL& pHandled )
84 {
85 //switch(msg) {
86 // case WM_SIZE: on_size(); break;
87 // case WM_MOVE: on_move(); break;
88 //}
89 return 0;
90 }
91
92 LRESULT SC_CALLBACK window::msg_delegate(HWINDOW hwnd, UINT msg, WPARAM wParam, LPARAM lParam, LPVOID pParam, BOOL* pHandled)
93 {
94 window* win = static_cast<window*>( pParam );
95 return win->on_message( hwnd, msg, wParam, lParam,*pHandled);
96 }
97
99 if(_hwnd) ::ShowWindow(_hwnd, SW_MINIMIZE );
100 }
102 if(_hwnd) ::ShowWindow(_hwnd, maximize? SW_MAXIMIZE :SW_NORMAL );
103 }
105 if(_hwnd) ::PostMessage(_hwnd, WM_CLOSE, 0, 0 );
106 }
107
109 {
111 if( _hwnd ) {
112 add_ref();
113 setup_callback();
114 sciter::attach_dom_event_handler(get_hwnd(),this);
115 }
116 }
117
118 }
119
bool load(aux::bytes utf8_html, const WCHAR *base_url=0)
int uimain(std::function< int()> run)
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
BOOL SCAPI SciterSetOption(HWINDOW hWnd, UINT option, UINT_PTR value)
BOOL SCAPI SciterLoadHtml(HWINDOW hWndSciter, LPCBYTE html, UINT htmlSize, LPCWSTR baseUrl)
HWINDOW SCAPI SciterCreateWindow(UINT creationFlags, LPRECT frame, SciterWindowDelegate *delegate, LPVOID delegateParam, HWINDOW parent)
window(UINT creationFlags, RECT frame=RECT())
void expand(bool maximize=false)
BOOL SCAPI SciterLoadFile(HWINDOW hWndSciter, LPCWSTR filename)
const std::vector< sciter::string > & argv()