comparison os2/dw.c @ 172:0fc45e386376

Get Dynamic Windows building with Watcom.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 01 Dec 2002 11:11:41 +0000
parents b8e93557b2c7
children 75bf3051235f
comparison
equal deleted inserted replaced
171:b8e93557b2c7 172:0fc45e386376
2198 2198
2199 if(tmp) 2199 if(tmp)
2200 tmp = tmp->next; 2200 tmp = tmp->next;
2201 2201
2202 } 2202 }
2203
2204 return (MRESULT)result; 2203 return (MRESULT)result;
2205 } 2204 }
2206 2205
2207 /* Handles control messages sent to the box (owner). */ 2206 /* Handles control messages sent to the box (owner). */
2208 MRESULT EXPENTRY _controlproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2) 2207 MRESULT EXPENTRY _controlproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
4209 * id: An ID to be used with WinWindowFromID() or 0L. 4208 * id: An ID to be used with WinWindowFromID() or 0L.
4210 */ 4209 */
4211 HWND dw_slider_new(int vertical, int increments, ULONG id) 4210 HWND dw_slider_new(int vertical, int increments, ULONG id)
4212 { 4211 {
4213 WindowData *blah = calloc(1, sizeof(WindowData)); 4212 WindowData *blah = calloc(1, sizeof(WindowData));
4214 SLDCDATA sldcData = { sizeof(SLDCDATA), increments, 0, 0, 0 }; 4213 SLDCDATA sldcData = { 0, 0, 0, 0, 0 };
4215 HWND tmp = WinCreateWindow(HWND_OBJECT, 4214 HWND tmp = WinCreateWindow(HWND_OBJECT,
4216 WC_SLIDER, 4215 WC_SLIDER,
4217 "", 4216 "",
4218 WS_VISIBLE | SLS_SNAPTOINCREMENT | 4217 WS_VISIBLE | SLS_SNAPTOINCREMENT |
4219 (vertical ? SLS_VERTICAL : SLS_HORIZONTAL), 4218 (vertical ? SLS_VERTICAL : SLS_HORIZONTAL),
4222 HWND_TOP, 4221 HWND_TOP,
4223 id, 4222 id,
4224 &sldcData, 4223 &sldcData,
4225 NULL); 4224 NULL);
4226 4225
4226 sldcData.cbSize = sizeof(SLDCDATA);
4227 sldcData.usScale1Increments = increments;
4227 4228
4228 blah->oldproc = WinSubclassWindow(tmp, _entryproc); 4229 blah->oldproc = WinSubclassWindow(tmp, _entryproc);
4229 WinSetWindowPtr(tmp, QWP_USER, blah); 4230 WinSetWindowPtr(tmp, QWP_USER, blah);
4230 return tmp; 4231 return tmp;
4231 } 4232 }
4360 * Returns: 4361 * Returns:
4361 * text: The text associsated with a given window. 4362 * text: The text associsated with a given window.
4362 */ 4363 */
4363 char *dw_window_get_text(HWND handle) 4364 char *dw_window_get_text(HWND handle)
4364 { 4365 {
4365 char tempbuf[4096] = ""; 4366 int len = WinQueryWindowTextLength(handle);
4366 4367 char *tempbuf = calloc(1, len + 2);
4367 WinQueryWindowText(handle, 4095, tempbuf); 4368
4368 tempbuf[4095] = 0; 4369 WinQueryWindowText(handle, len + 1, tempbuf);
4369 4370
4370 return strdup(tempbuf); 4371 return tempbuf;
4371 } 4372 }
4372 4373
4373 /* 4374 /*
4374 * Disables given window (widget). 4375 * Disables given window (widget).
4375 * Parameters: 4376 * Parameters:
7070 */ 7071 */
7071 ULONG ulBootDrive = 0; 7072 ULONG ulBootDrive = 0;
7072 ULONG ulBuild = 0; 7073 ULONG ulBuild = 0;
7073 if (DosQuerySysInfo (QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &ulBootDrive, sizeof (ulBootDrive)) == NO_ERROR) 7074 if (DosQuerySysInfo (QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &ulBootDrive, sizeof (ulBootDrive)) == NO_ERROR)
7074 { 7075 {
7075 char achFileName[11] = { (char)('A'+ulBootDrive-1),':','\\','O','S','2','K','R','N','L','\0' }; 7076 char achFileName[11] = "C:\\OS2KRNL";
7076 HFILE hfile; 7077 HFILE hfile;
7077 ULONG ulResult; 7078 ULONG ulResult;
7079
7080 achFileName[0] = (char)('A'+ulBootDrive-1);
7081
7078 if (DosOpen (achFileName, &hfile, &ulResult, 0, 0, OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS, OPEN_FLAGS_FAIL_ON_ERROR | OPEN_FLAGS_NO_CACHE | OPEN_FLAGS_SEQUENTIAL | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, NULL) == NO_ERROR) 7082 if (DosOpen (achFileName, &hfile, &ulResult, 0, 0, OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS, OPEN_FLAGS_FAIL_ON_ERROR | OPEN_FLAGS_NO_CACHE | OPEN_FLAGS_SEQUENTIAL | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, NULL) == NO_ERROR)
7079 { 7083 {
7080 ULONG ulFileSize = 0; 7084 ULONG ulFileSize = 0;
7081 if (DosSetFilePtr (hfile, 0, FILE_END, &ulFileSize) == NO_ERROR) 7085 if (DosSetFilePtr (hfile, 0, FILE_END, &ulFileSize) == NO_ERROR)
7082 { 7086 {
7253 } 7257 }
7254 7258
7255 /* Internal function to set drive and directory */ 7259 /* Internal function to set drive and directory */
7256 int _SetPath(char *path) 7260 int _SetPath(char *path)
7257 { 7261 {
7262 #ifndef __WATCOMC__
7258 if(strlen(path) > 2) 7263 if(strlen(path) > 2)
7259 { 7264 {
7260 if(path[1] == ':') 7265 if(path[1] == ':')
7261 { 7266 {
7262 char drive = toupper(path[0]); 7267 char drive = toupper(path[0]);
7263 _chdrive((drive - 'A')+1); 7268 _chdrive((drive - 'A')+1);
7264 } 7269 }
7265 } 7270 }
7271 #endif
7266 return chdir(path); 7272 return chdir(path);
7267 } 7273 }
7268 7274
7269 /* 7275 /*
7270 * Execute and external program in a seperate session. 7276 * Execute and external program in a seperate session.
7314 if(len > 0) 7320 if(len > 0)
7315 { 7321 {
7316 if(stricmp(&browser[len], "explore.exe") == 0) 7322 if(stricmp(&browser[len], "explore.exe") == 0)
7317 { 7323 {
7318 int newlen, z; 7324 int newlen, z;
7319 newurl = alloca(strlen(url) + 2); 7325 newurl = malloc(strlen(url) + 2);
7320 sprintf(newurl, "file:///%s", &url[7]); 7326 sprintf(newurl, "file:///%s", &url[7]);
7321 newlen = strlen(newurl); 7327 newlen = strlen(newurl);
7322 for(z=8;z<(newlen-8);z++) 7328 for(z=8;z<(newlen-8);z++)
7323 { 7329 {
7324 if(newurl[z] == '|') 7330 if(newurl[z] == '|')
7335 if(olddir) 7341 if(olddir)
7336 { 7342 {
7337 _SetPath(olddir); 7343 _SetPath(olddir);
7338 free(olddir); 7344 free(olddir);
7339 } 7345 }
7346 if(newurl)
7347 free(newurl);
7340 return ret; 7348 return ret;
7341 } 7349 }
7342 7350
7343 /* 7351 /*
7344 * Returns a pointer to a static buffer which containes the 7352 * Returns a pointer to a static buffer which containes the