add custom cursor support

This commit is contained in:
cxgeorge
2001-09-19 23:29:15 +00:00
parent 12fbeebc6f
commit 85e3e867b4
6 changed files with 66 additions and 9 deletions

View File

@@ -62,8 +62,14 @@ init_libwdxdisplay() {
wdxGraphicsWindow::make_wdxGraphicsWindow);
}
// cant use global var cleanly because global var static init executed after init_libwgl(), incorrectly reiniting var
// cant use global var cleanly because global var static init executed after init_libwdxdisplay(), incorrectly reiniting var
Filename get_icon_filename() {
string iconname = config_wdxdisplay.GetString("win32-window-icon","");
return ExecutionEnvironment::expand_string(iconname);
}
// cant use global var cleanly because global var static init executed after init_libwdxdisplay(), incorrectly reiniting var
Filename get_cursor_filename() {
string cursorname = config_wdxdisplay.GetString("win32-cursor","");
return ExecutionEnvironment::expand_string(cursorname);
}

View File

@@ -28,6 +28,7 @@ NotifyCategoryDecl(wdxdisplay, EXPCL_PANDADX, EXPTP_PANDADX);
extern bool bResponsive_minimized_fullscreen_window;
extern bool dx_force_16bpp_zbuffer;
extern Filename get_icon_filename();
extern Filename get_cursor_filename();
extern EXPCL_PANDADX void init_libwdxdisplay();

View File

@@ -845,16 +845,37 @@ void wdxGraphicsWindow::config(void) {
wc.hInstance = hinstance;
string windows_icon_filename = get_icon_filename().to_os_specific();
string windows_cursor_filename = get_cursor_filename().to_os_specific();
if(!windows_icon_filename.empty()) {
// Note: LoadImage seems to cause win2k internal heap corruption (outputdbgstr warnings)
// if icon is more than 8bpp
// loads a .ico fmt file
wc.hIcon = (HICON) LoadImage(NULL, windows_icon_filename.c_str(), IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
if(wc.hIcon==NULL) {
wdxdisplay_cat.warning() << "windows icon filename '" << windows_icon_filename << "' not found!!\n";
}
} else {
wc.hIcon = NULL; // use default app icon
}
wc.hCursor = _hMouseCursor = LoadCursor(NULL, IDC_ARROW);
if(!windows_cursor_filename.empty()) {
// Note: LoadImage seems to cause win2k internal heap corruption (outputdbgstr warnings)
// if icon is more than 8bpp
// loads a .cur fmt file
_hMouseCursor = (HCURSOR) LoadImage(NULL, windows_cursor_filename.c_str(), IMAGE_CURSOR, 0, 0, LR_LOADFROMFILE);
if(_hMouseCursor==NULL) {
wdxdisplay_cat.warning() << "windows cursor filename '" << windows_cursor_filename << "' not found!!\n";
}
} else {
_hMouseCursor = LoadCursor(NULL, IDC_ARROW);
}
wc.hCursor = _hMouseCursor;
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = WDX_WINDOWCLASSNAME;

View File

@@ -71,8 +71,12 @@ init_libwgldisplay() {
}
// cant use global var cleanly because global var static init executed after init_libwgl(), incorrectly reiniting var
Filename get_icon_filename_() {
Filename get_icon_filename_2() {
string iconname = config_wgldisplay.GetString("win32-window-icon","");
return ExecutionEnvironment::expand_string(iconname);
}
Filename get_cursor_filename_2() {
string cursorname = config_wgldisplay.GetString("win32-cursor","");
return ExecutionEnvironment::expand_string(cursorname);
}

View File

@@ -25,7 +25,11 @@
NotifyCategoryDecl(wgldisplay, EXPCL_PANDAGL, EXPTP_PANDAGL);
extern Filename get_icon_filename_();
// for some reason there is a conflict with the pandadx versions of get_icon_filename during linking,
// so appended '_2' to name
extern Filename get_icon_filename_2();
extern Filename get_cursor_filename_2();
extern bool gl_show_fps_meter;
extern float gl_fps_meter_update_interval;
extern bool gl_sync_video;

View File

@@ -315,18 +315,39 @@ void wglGraphicsWindow::config(void) {
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wc.lpfnWndProc = (WNDPROC) static_window_proc;
wc.hInstance = hinstance;
string windows_icon_filename = get_icon_filename_().to_os_specific();
string windows_icon_filename = get_icon_filename_2().to_os_specific();
string windows_cursor_filename = get_cursor_filename_2().to_os_specific();
if(!windows_icon_filename.empty()) {
// Note: LoadImage seems to cause win2k internal heap corruption (outputdbgstr warnings)
// if icon is more than 8bpp
// loads a .ico fmt file
wc.hIcon = (HICON) LoadImage(NULL, windows_icon_filename.c_str(), IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
if(wc.hIcon==NULL) {
wgldisplay_cat.warning() << "windows icon filename '" << windows_icon_filename << "' not found!!\n";
}
} else {
wc.hIcon = NULL; // use default app icon
}
wc.hCursor = _hMouseCursor = LoadCursor(NULL, IDC_ARROW);
if(!windows_cursor_filename.empty()) {
// Note: LoadImage seems to cause win2k internal heap corruption (outputdbgstr warnings)
// if icon is more than 8bpp
// loads a .cur fmt file
_hMouseCursor = (HCURSOR) LoadImage(NULL, windows_cursor_filename.c_str(), IMAGE_CURSOR, 0, 0, LR_LOADFROMFILE);
if(_hMouseCursor==NULL) {
wgldisplay_cat.warning() << "windows cursor filename '" << windows_cursor_filename << "' not found!!\n";
}
} else {
_hMouseCursor = LoadCursor(NULL, IDC_ARROW);
}
wc.hCursor = _hMouseCursor;
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = WGL_WINDOWCLASSNAME;