Sciter: F:/hsmile5/sdk/include/sciter-win-main.cpp Source File

Sciter  3.3.2.5
Sciter API
sciter-win-main.cpp
Go to the documentation of this file.
1 #include "stdafx.h"
2 
3 #include <vector>
4 
5 #include "sciter-x-window.hpp"
6 
7  #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
8 // Windows Header Files:
9 #include <windows.h>
10 
11  HINSTANCE ghInstance = 0;
12 
13  int APIENTRY wWinMain(HINSTANCE hInstance,
14  HINSTANCE hPrevInstance,
15  LPWSTR lpCmdLine,
16  int nCmdShow)
17 {
18  ghInstance = hInstance;
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
26  ::SciterSetOption(NULL,SCITER_SET_UX_THEMING,TRUE);
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 
47 namespace sciter {
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 
65  HINSTANCE hinstance() {
66  return ghInstance;
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  {
76  return FALSE != ::SciterLoadHtml(_hwnd,(LPCBYTE)utf8_html.start,utf8_html.length, base_url);
77  }
78  bool window::load( const WCHAR* url)
79  {
80  return FALSE != ::SciterLoadFile(_hwnd,url);
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 
98  void window::collapse() {
99  if(_hwnd) ::ShowWindow(_hwnd, SW_MINIMIZE );
100  }
101  void window::expand( bool maximize) {
102  if(_hwnd) ::ShowWindow(_hwnd, maximize? SW_MAXIMIZE :SW_NORMAL );
103  }
104  void window::dismiss() {
105  if(_hwnd) ::PostMessage(_hwnd, WM_CLOSE, 0, 0 );
106  }
107 
108  window::window( UINT creationFlags, RECT frame): _hwnd(NULL)
109  {
110  _hwnd = ::SciterCreateWindow(creationFlags,&frame,&msg_delegate,this,NULL);
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)
const BYTE * LPCBYTE
HINSTANCE ghInstance
BOOL SCAPI SciterSetOption(HWINDOW hWnd, UINT option, UINT_PTR value)
Definition: sciter-x-api.h:458
BOOL SCAPI SciterLoadHtml(HWINDOW hWndSciter, LPCBYTE html, UINT htmlSize, LPCWSTR baseUrl)
Definition: sciter-x-api.h:443
HWINDOW SCAPI SciterCreateWindow(UINT creationFlags, LPRECT frame, SciterWindowDelegate *delegate, LPVOID delegateParam, HWINDOW parent)
Definition: sciter-x-api.h:471
window(UINT creationFlags, RECT frame=RECT())
void expand(bool maximize=false)
HINSTANCE hinstance()
BOOL SCAPI SciterLoadFile(HWINDOW hWndSciter, LPCWSTR filename)
Definition: sciter-x-api.h:442
const std::vector< sciter::string > & argv()

AltStyle によって変換されたページ (->オリジナル) /