3 #include "gui/MainDlgFrame.h"
4 #include "controllers/ScopeController.h"
5 #include "controllers/ScopeLogger.h"
12 uint8_t mylutfunc(
const double& e) {
13 return (uint8_t)(255*std::sin(e));
17 int Run(HINSTANCE hInstance) {
22 ::PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE);
25 _Module.AddMessageLoop(&theLoop);
28 CString filepath = L
"default.xml";
29 bool founddefault =
false;
30 HANDLE defaultfile = CreateFile(filepath.GetString(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
33 INT_PTR dlgret = IDCANCEL;
34 if ( defaultfile == INVALID_HANDLE_VALUE ) {
35 COMDLG_FILTERSPEC fileTypes[] = {{ L
"Scope XML parameter file", L
"*.xml" }};
36 CShellFileOpenDialog dlg(NULL, FOS_FORCEFILESYSTEM | FOS_PATHMUSTEXIST | FOS_FILEMUSTEXIST, L
"xml", fileTypes, 1);
37 dlg.GetPtr()->SetTitle(L
"Select Scope XML parameter file");
38 IShellItem *psiFolder;
39 SHCreateItemFromParsingName(L
"C:\\Temp\\", NULL, IID_PPV_ARGS(&psiFolder));
40 dlg.GetPtr()->SetFolder(psiFolder);
41 dlgret = dlg.DoModal();
43 dlg.GetFilePath(filepath);
49 std::vector<wchar_t> buff(512);
50 GetFinalPathNameByHandle(defaultfile, buff.data(), 512, FILE_NAME_NORMALIZED);
51 filepath.SetString(buff.data());
52 CloseHandle(defaultfile);
56 if ( founddefault || (dlgret == IDOK) ) {
57 DBOUT(L
"Filepath " << filepath.GetString());
64 scope_controller.LoadParameters(std::wstring(filepath.GetString()));
69 std::this_thread::sleep_for(std::chrono::milliseconds(20));
74 DBOUT(L
"Sizeof parameters::Scope " <<
sizeof(scope_controller.GuiParameters));
78 RECT rec = {20,20,440,980};
79 if(wndMain.CreateEx(HWND(0), rec) == NULL)
80 throw (std::exception(
"Main window creation failed"));
82 wndMain.ShowWindow(SW_SHOWDEFAULT);
85 std::wstring revstr = CA2W(STR(LASTGITCOMMIT));
86 revstr = L
"Scope (Git commit " + revstr + L
")";
87 wndMain.SetWindowText(revstr.c_str());
90 std::wstring msg(L
"This is Scope (Git commit ");
91 msg += CA2W(STR(LASTGITCOMMIT));
93 logger.
Log(msg, scope::log_info);
94 msg = L
"Using configuration file " + filepath;
95 logger.
Log(msg, scope::log_info);
102 ::MessageBox(NULL, L
"No default parameter file found and no parameter file choosen!", L
"Choose wisely next time", MB_OK | MB_ICONWARNING | MB_TASKMODAL | MB_SETFOREGROUND | MB_TOPMOST);
111 int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE , LPTSTR lpstrCmdLine,
int nCmdShow) {
120 HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
122 ATLASSERT(SUCCEEDED(hRes));
125 assert( RunTimeHelper::IsWin7() );
128 ::DefWindowProc(HWND(NULL), 0, 0, 0L);
131 AtlInitCommonControls(ICC_COOL_CLASSES | ICC_BAR_CLASSES | ICC_USEREX_CLASSES | ICC_STANDARD_CLASSES);
133 hRes =
_Module.Init(NULL, hInstance);
134 assert(SUCCEEDED(hRes));
137 HMODULE hInstRich = ::LoadLibrary(CRichEditCtrl::GetLibraryName());
138 assert(hInstRich != NULL);
140 int32_t nRet =
Run(hInstance);
143 ::FreeLibrary(hInstRich);
Main controller of microscope hardware and acquisition, also interface to the GUI.
The main application dialog frame.
void SetFilepath(const std::wstring &_filepath=L"C:\\ScopeData")
Sets the filepath and creates logfile.
A logger class to log various messages and user comments.
int Run(HINSTANCE hInstance)
Run the main message loop.
This is the include file for standard system include files, or project specific include files that ar...
void Log(const std::wstring &message, const log_message_type &msgtype)
Logs a message.
std::wstring GetCurrentDateString()
void Shutdown()
Calls ScopeLogger::Impl::Shutdown.
#define DBOUT(s)
A debug output to the debug console.
CAppModule _Module
The ATL application module.
void Version()
Print the current ScopeController version to debug console.