Add address box and cleanup
This commit is contained in:
		
							parent
							
								
									163a583fa4
								
							
						
					
					
						commit
						032cd334ae
					
				
										
											Binary file not shown.
										
									
								
							| @ -7,6 +7,7 @@ | ||||
| #define IDC_STATICTITLE                 1001 | ||||
| #define IDC_BUTTONEXIT                  1003 | ||||
| #define IDC_BUTTONCONNECT               1005 | ||||
| #define IDC_EDITADDRESS                 1006 | ||||
| #define ID_FILE_EXIT                    40001 | ||||
| #define ID_HELP_ABOUT                   40002 | ||||
| 
 | ||||
| @ -16,7 +17,7 @@ | ||||
| #ifndef APSTUDIO_READONLY_SYMBOLS | ||||
| #define _APS_NEXT_RESOURCE_VALUE        106 | ||||
| #define _APS_NEXT_COMMAND_VALUE         40003 | ||||
| #define _APS_NEXT_CONTROL_VALUE         1006 | ||||
| #define _APS_NEXT_CONTROL_VALUE         1007 | ||||
| #define _APS_NEXT_SYMED_VALUE           101 | ||||
| #endif | ||||
| #endif | ||||
|  | ||||
| @ -3,6 +3,8 @@ | ||||
| #include <iostream> | ||||
| #include <format> | ||||
| 
 | ||||
| #include <CommCtrl.h> | ||||
| 
 | ||||
| #include "../resource.h" | ||||
| 
 | ||||
| //This pragma enables visual styles, which makes dialogs and their controls look modern.
 | ||||
| @ -12,15 +14,14 @@ processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") | ||||
| 
 | ||||
| namespace wc { | ||||
| 	Application::Application(std::string& appName, std::string& appVersion) | ||||
| 		: m_appName(appName) | ||||
| 		, m_appVersion(appVersion) | ||||
| 		: m_appName(appName.begin(), appName.end()) | ||||
| 		, m_appVersion(appVersion.begin(), appVersion.end()) | ||||
| 	{ | ||||
| 		std::cout << std::format("{} {}", m_appName, m_appVersion); | ||||
| 		std::wcout << std::format(L"{} {}", m_appName, m_appVersion); | ||||
| 	} | ||||
| 
 | ||||
| 	void Application::run() { | ||||
| 		HINSTANCE hInst = GetModuleHandle(NULL); | ||||
| 		DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_DIALOGMAIN), nullptr, (DLGPROC)dlgProc, reinterpret_cast<LPARAM>(this)); | ||||
| 		DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOGMAIN), nullptr, (DLGPROC)dlgProc, reinterpret_cast<LPARAM>(this)); | ||||
| 	} | ||||
| 
 | ||||
| 	BOOL CALLBACK Application::dlgProc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam) { | ||||
| @ -30,40 +31,37 @@ namespace wc { | ||||
| 			case WM_INITDIALOG: { | ||||
| 				app = reinterpret_cast<Application*>(lParam); | ||||
| 
 | ||||
| 				std::wstring appName(app->m_appName.begin(), app->m_appName.end()); | ||||
| 				SetWindowText(dlg, appName.c_str()); | ||||
| 				SetWindowText(dlg, app->m_appName.c_str()); | ||||
| 
 | ||||
| 				POINT pt = { }; | ||||
| 				GetCursorPos(&pt); | ||||
| 				HMONITOR mon = MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST); | ||||
| 				MONITORINFO mi = { }; | ||||
| 				mi.cbSize = sizeof(mi); | ||||
| 				GetMonitorInfo(mon, &mi); | ||||
| 
 | ||||
| 				GetMonitorInfo(MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST), &mi); | ||||
| 				SetWindowPos(dlg, nullptr, mi.rcMonitor.left + 100, mi.rcMonitor.top + 100, 0, 0, SWP_NOSIZE | SWP_NOZORDER); | ||||
| 
 | ||||
| 				SetDlgItemText(dlg, IDC_STATICTITLE, appName.c_str()); | ||||
| 
 | ||||
| 				SetDlgItemText(dlg, IDC_STATICTITLE, app->m_appName.c_str()); | ||||
| 				LOGFONT lFont = { }; | ||||
| 				lFont.lfHeight = 50; | ||||
| 
 | ||||
| 				HFONT font = CreateFontIndirect(&lFont); | ||||
| 				SendMessage(GetDlgItem(dlg, IDC_STATICTITLE), WM_SETFONT, reinterpret_cast<LPARAM>(font), NULL); | ||||
| 
 | ||||
| 				SendDlgItemMessage(dlg, IDC_EDITADDRESS, EM_SETCUEBANNER, TRUE, reinterpret_cast<LPARAM>(L"Address")); | ||||
| 				return TRUE; | ||||
| 			} | ||||
| 
 | ||||
| 			case WM_COMMAND: | ||||
| 				switch (LOWORD(wParam)) { | ||||
| 					case IDC_BUTTONCONNECT: | ||||
| 
 | ||||
| 					case IDC_BUTTONCONNECT: { | ||||
| 						std::wstring address; | ||||
| 						address.resize(GetWindowTextLength(GetDlgItem(dlg, IDC_EDITADDRESS)) + 1); | ||||
| 						GetDlgItemText(dlg, IDC_EDITADDRESS, address.data(), static_cast<int>(address.size())); | ||||
| 						MessageBox(dlg, std::format(L"Address: {}", address).c_str(), L"Alert", MB_OK); | ||||
| 						return TRUE; | ||||
| 					} | ||||
| 
 | ||||
| 					case ID_HELP_ABOUT: { | ||||
| 						std::wstring appName(app->m_appName.begin(), app->m_appName.end()); | ||||
| 						std::wstring appVer(app->m_appVersion.begin(), app->m_appVersion.end()); | ||||
| 						std::wstring aboutStr = std::format(L"{} {}\nGrayson Riffe 2023", appName, appVer); | ||||
| 						MessageBox(dlg, aboutStr.c_str(), L"About", MB_OK); | ||||
| 						MessageBox(dlg, std::format(L"{} {}\nGrayson Riffe 2023", app->m_appName, app->m_appVersion).c_str(), L"About", MB_OK); | ||||
| 						return TRUE; | ||||
| 					} | ||||
| 
 | ||||
|  | ||||
| @ -12,9 +12,10 @@ namespace wc { | ||||
| 
 | ||||
| 		~Application(); | ||||
| 	private: | ||||
| 
 | ||||
| 		static BOOL CALLBACK dlgProc(HWND dlg, UINT msg, WPARAM wParam, LPARAM lParam); | ||||
| 
 | ||||
| 		const std::string m_appName; | ||||
| 		const std::string m_appVersion; | ||||
| 		const std::wstring m_appName; | ||||
| 		const std::wstring m_appVersion; | ||||
| 	}; | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user