Mercurial > dwindows
comparison win/dw.c @ 2125:37758cfed67b
Win: Move the fallback AppID creation above _dw_edge_detect() call.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 25 Jun 2020 00:59:32 +0000 |
parents | f9a2fc59611c |
children | 97839ff3c985 |
comparison
equal
deleted
inserted
replaced
2124:f9a2fc59611c | 2125:37758cfed67b |
---|---|
4429 { | 4429 { |
4430 dw_messagebox("Dynamic Windows", DW_MB_OK|DW_MB_ERROR, "Could not initialize the object window. error code %d", GetLastError()); | 4430 dw_messagebox("Dynamic Windows", DW_MB_OK|DW_MB_ERROR, "Could not initialize the object window. error code %d", GetLastError()); |
4431 exit(1); | 4431 exit(1); |
4432 } | 4432 } |
4433 | 4433 |
4434 #if (defined(BUILD_DLL) || defined(BUILD_HTML)) | |
4435 /* Register HTML renderer class */ | |
4436 memset(&wc, 0, sizeof(WNDCLASS)); | |
4437 wc.lpszClassName = BrowserClassName; | |
4438 wc.style = CS_HREDRAW | CS_VREDRAW; | |
4439 #ifdef BUILD_EDGE | |
4440 /* Check if Microsoft Edge (Chromium) is installed */ | |
4441 if (_DW_EDGE_DETECTED = _dw_edge_detect(UTF8toWide(_dw_app_id))) | |
4442 { | |
4443 wc.lpfnWndProc = (WNDPROC)_edgeWindowProc; | |
4444 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); | |
4445 } | |
4446 else | |
4447 #endif | |
4448 { | |
4449 wc.lpfnWndProc = (WNDPROC)_browserWindowProc; | |
4450 } | |
4451 RegisterClass(&wc); | |
4452 #endif | |
4453 | |
4454 /* Create a tooltip. */ | |
4455 hwndTooltip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, | |
4456 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, DW_HWND_OBJECT, NULL, DWInstance,NULL); | |
4457 | |
4458 SetWindowPos(hwndTooltip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); | |
4459 | |
4460 /* Create empty box data */ | |
4461 SetWindowLongPtr(DW_HWND_OBJECT, GWLP_USERDATA, (LONG_PTR)calloc(sizeof(Box), 1)); | |
4462 | |
4463 /* Initialize Security for named events and memory */ | |
4464 InitializeSecurityDescriptor(&_dwsd, SECURITY_DESCRIPTOR_REVISION); | |
4465 SetSecurityDescriptorDacl(&_dwsd, TRUE, (PACL) NULL, FALSE); | |
4466 | |
4467 OleInitialize(NULL); | |
4468 | |
4469 /* | |
4470 * Get an alternate temporary directory in case TMP doesn't exist | |
4471 */ | |
4472 if ( (alttmpdir = getenv( "TEMP" ) ) == NULL ) | |
4473 { | |
4474 strcpy( _dw_alternate_temp_dir, "c:\\tmp" ); | |
4475 } | |
4476 else | |
4477 { | |
4478 strncpy( _dw_alternate_temp_dir, alttmpdir, MAX_PATH ); | |
4479 } | |
4480 | |
4481 #ifdef GDIPLUS | |
4482 /* Setup GDI+ */ | |
4483 si.GdiplusVersion = 1; | |
4484 si.DebugEventCallback = NULL; | |
4485 si.SuppressBackgroundThread = FALSE; | |
4486 si.SuppressExternalCodecs = FALSE; | |
4487 GdiplusStartup(&gdiplusToken, &si, NULL); | |
4488 #endif | |
4489 | |
4490 /* GDI+ Needs to be initialized before calling _dw_init_thread(); */ | |
4491 _dw_init_thread(); | |
4492 | |
4493 #ifdef RICHEDIT | |
4494 /* Attempt to load rich edit library: 4.1, 3/2.0 and 1.0 */ | |
4495 if(!(hmsftedit = LoadLibrary(TEXT("msftedit")))) | |
4496 { | |
4497 if(!(hrichedit = LoadLibrary(TEXT("riched20")))) | |
4498 hrichedit = LoadLibrary(TEXT("riched32")); | |
4499 } | |
4500 #endif | |
4501 if(!_dw_app_id[0]) | 4434 if(!_dw_app_id[0]) |
4502 { | 4435 { |
4503 /* Generate an Application ID based on the PID if all else fails. */ | 4436 /* Generate an Application ID based on the PID if all else fails. */ |
4504 snprintf(_dw_app_id, 100, "%s.pid.%d", DW_APP_DOMAIN_DEFAULT, getpid()); | 4437 snprintf(_dw_app_id, 100, "%s.pid.%d", DW_APP_DOMAIN_DEFAULT, getpid()); |
4505 } | 4438 } |
4511 pos = strrchr(fullpath, '\\'); | 4444 pos = strrchr(fullpath, '\\'); |
4512 if(pos) | 4445 if(pos) |
4513 pos++; | 4446 pos++; |
4514 strncpy(_dw_app_name, pos ? pos : fullpath, 100); | 4447 strncpy(_dw_app_name, pos ? pos : fullpath, 100); |
4515 } | 4448 } |
4449 | |
4450 #if (defined(BUILD_DLL) || defined(BUILD_HTML)) | |
4451 /* Register HTML renderer class */ | |
4452 memset(&wc, 0, sizeof(WNDCLASS)); | |
4453 wc.lpszClassName = BrowserClassName; | |
4454 wc.style = CS_HREDRAW | CS_VREDRAW; | |
4455 #ifdef BUILD_EDGE | |
4456 /* Check if Microsoft Edge (Chromium) is installed */ | |
4457 if (_DW_EDGE_DETECTED = _dw_edge_detect(UTF8toWide(_dw_app_id))) | |
4458 { | |
4459 wc.lpfnWndProc = (WNDPROC)_edgeWindowProc; | |
4460 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); | |
4461 } | |
4462 else | |
4463 #endif | |
4464 { | |
4465 wc.lpfnWndProc = (WNDPROC)_browserWindowProc; | |
4466 } | |
4467 RegisterClass(&wc); | |
4468 #endif | |
4469 | |
4470 /* Create a tooltip. */ | |
4471 hwndTooltip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, | |
4472 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, DW_HWND_OBJECT, NULL, DWInstance,NULL); | |
4473 | |
4474 SetWindowPos(hwndTooltip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); | |
4475 | |
4476 /* Create empty box data */ | |
4477 SetWindowLongPtr(DW_HWND_OBJECT, GWLP_USERDATA, (LONG_PTR)calloc(sizeof(Box), 1)); | |
4478 | |
4479 /* Initialize Security for named events and memory */ | |
4480 InitializeSecurityDescriptor(&_dwsd, SECURITY_DESCRIPTOR_REVISION); | |
4481 SetSecurityDescriptorDacl(&_dwsd, TRUE, (PACL) NULL, FALSE); | |
4482 | |
4483 OleInitialize(NULL); | |
4484 | |
4485 /* | |
4486 * Get an alternate temporary directory in case TMP doesn't exist | |
4487 */ | |
4488 if ( (alttmpdir = getenv( "TEMP" ) ) == NULL ) | |
4489 { | |
4490 strcpy( _dw_alternate_temp_dir, "c:\\tmp" ); | |
4491 } | |
4492 else | |
4493 { | |
4494 strncpy( _dw_alternate_temp_dir, alttmpdir, MAX_PATH ); | |
4495 } | |
4496 | |
4497 #ifdef GDIPLUS | |
4498 /* Setup GDI+ */ | |
4499 si.GdiplusVersion = 1; | |
4500 si.DebugEventCallback = NULL; | |
4501 si.SuppressBackgroundThread = FALSE; | |
4502 si.SuppressExternalCodecs = FALSE; | |
4503 GdiplusStartup(&gdiplusToken, &si, NULL); | |
4504 #endif | |
4505 | |
4506 /* GDI+ Needs to be initialized before calling _dw_init_thread(); */ | |
4507 _dw_init_thread(); | |
4508 | |
4509 #ifdef RICHEDIT | |
4510 /* Attempt to load rich edit library: 4.1, 3/2.0 and 1.0 */ | |
4511 if(!(hmsftedit = LoadLibrary(TEXT("msftedit")))) | |
4512 { | |
4513 if(!(hrichedit = LoadLibrary(TEXT("riched20")))) | |
4514 hrichedit = LoadLibrary(TEXT("riched32")); | |
4515 } | |
4516 #endif | |
4516 #ifdef BUILD_TOAST | 4517 #ifdef BUILD_TOAST |
4517 _dw_toast_init(UTF8toWide(_dw_app_name), UTF8toWide(_dw_app_id)); | 4518 _dw_toast_init(UTF8toWide(_dw_app_name), UTF8toWide(_dw_app_id)); |
4518 #endif | 4519 #endif |
4519 return 0; | 4520 return 0; |
4520 } | 4521 } |