Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[r8584]: ooDialog / trunk / ooDialog / oodCommon.hpp Maximize Restore History

Download this file

oodCommon.hpp    725 lines (651 with data), 31.5 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
/*----------------------------------------------------------------------------*/
/* */
/* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */
/* Copyright (c) 2005-2012 Rexx Language Association. All rights reserved. */
/* */
/* This program and the accompanying materials are made available under */
/* the terms of the Common Public License v1.0 which accompanies this */
/* distribution. A copy is also available at the following address: */
/* http://www.oorexx.org/license.html */
/* */
/* Redistribution and use in source and binary forms, with or */
/* without modification, are permitted provided that the following */
/* conditions are met: */
/* */
/* Redistributions of source code must retain the above copyright */
/* notice, this list of conditions and the following disclaimer. */
/* Redistributions in binary form must reproduce the above copyright */
/* notice, this list of conditions and the following disclaimer in */
/* the documentation and/or other materials provided with the distribution. */
/* */
/* Neither the name of Rexx Language Association nor the names */
/* of its contributors may be used to endorse or promote products */
/* derived from this software without specific prior written permission. */
/* */
/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
/* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
/* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
/* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
/* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */
/* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
/* */
/*----------------------------------------------------------------------------*/
#ifndef oodCommon_Included
#define oodCommon_Included
// Map string keywords representing constant defines to their int values. For
// translating things like "IDI_APPLICATION" from the user to the proper API
// value.
#include <string>
#include <map>
using namespace std;
typedef map<string, int, less<string> > String2Int;
#define COMCTL_ERR_TITLE "ooDialog - Windows Common Controls Error"
#define DLLGETVERSION_FUNCTION "DllGetVersion"
#define COMMON_CONTROL_DLL "comctl32.dll"
#define NO_COMMCTRL_MSG "failed to initialize %s; OS error code %d"
#define NO_HMODULE_MSG "failed to obtain %s module handle; OS error code %d"
#define NO_PROC_MSG "failed to get procedeure adddress for %s(); OS error code %d"
#define API_FAILED_MSG "system API %s() failed; OS error code %d"
#define COM_API_FAILED_MSG "system API %s() failed; COM code 0x%08x"
#define FUNC_WINCTRL_FAILED_MSG "the '%s'() function of the Windows '%s' control failed"
#define MSG_WINCTRL_FAILED_MSG "the '%s' message of the Windows '%s' control failed"
#define NO_LOCAL_ENVIRONMENT_MSG "the .local environment was not found"
#define NO_SIZE_CLASS_MSG "the .Size class was not found"
#define BAD_APPLICATION_MSG "the .Application object already exists"
#define COMCTL32_FULL_PART 0
#define COMCTL32_NUMBER_PART 1
#define COMCTL32_OS_PART 2
#define OOD_RESOURCE_ERR_TITLE "ooDialog - Resource Definition Error"
#define OOD_ADDICONFILE_ERR_MSG "Icon resource elements have exceeded the maximum\n" \
"number of allocated icon table entries, and the\n" \
"table could not be expanded.\n\n" \
"The icon resource will not be added."
// ooDialog return codes for special purposes, including some int32_t codes
// where -1 and greater is valid.
#define OOD_ID_EXCEPTION 0xFFFFFFF7 // -9
#define OOD_INVALID_ITEM_ID 0xFFFFFFF7 // Rewording of OOD_ID_EXCEPTION
#define OOD_BAD_WIDTH_EXCEPTION 0xFFFFFFF8 // -8
#define OOD_MEMORY_ERR 0xFFFFFFF9 // -7
#define OOD_NO_VALUE 0xFFFFFFFA // -6
#define OOD_NO_ERROR 0
#define OOD_DATATABLE_FULL 1
// Tool tip stuff
#define MAX_TOOLTITLE_TEXT_LENGTH 99
#define TT_CCH_TOOLTITLE_BUF MAX_TOOLTITLE_TEXT_LENGTH + 1
#define TT_MAX_ICON_KEYWORD TTI_ERROR_LARGE
#define TT_VALID_ICON_VALUES "an icon Image object, or keyword: None, Error, ErrorLarge, Info, InfoLarge, Warning, or WarningLarge"
// The context variable names used by the ToolInfo object to keep track of
// things.
#define TOOLINFO_MEMALLOCATED_VAR "TEXT_MEMORY_IS_ALLOCATED"
#define TOOLINFO_HWND_OBJECT_VAR "HWND_SUPPLYING_OBJECT"
#define TOOLINFO_UID_OBJECT_VAR "UID_SUPPLYING_OBJECT"
extern uint32_t keyword2ttdiFlags(CSTRING flags);
extern RexxStringObject ttdiFlags2keyword(RexxThreadContext *c, uint32_t flags);
/* Struct for a reply to the UDN_DELTAPOS notification message. (Up-down control.) */
typedef struct _DELTAPOS_REPLY {
bool change;
bool cancel;
int32_t newDelta;
} DELTAPOSREPLY;
typedef DELTAPOSREPLY *PDELTAPOSREPLY;
extern const char * comctl32VersionPart(DWORD id, DWORD type);
extern bool installNecessaryStuff(pCPlainBaseDialog pcpbd, CSTRING library);
extern int32_t stopDialog(pCPlainBaseDialog, RexxThreadContext *c);
extern int32_t delDialog(pCPlainBaseDialog, RexxThreadContext *c);
extern BOOL getDialogIcons(pCPlainBaseDialog, INT, UINT, PHANDLE, PHANDLE);
extern bool isYes(const char *s);
extern bool isPointerString(const char *string);
extern void * string2pointer(const char *string);
extern void * string2pointer(RexxMethodContext *c, RexxStringObject string);
extern void * string2pointer(RexxThreadContext *c, RexxObjectPtr ptr);
extern void pointer2string(char *, void *pointer);
extern RexxStringObject pointer2string(RexxMethodContext *, void *);
extern RexxStringObject pointer2string(RexxThreadContext *c, void *pointer);
extern RexxStringObject dword2string(RexxMethodContext *, uint32_t);
extern RexxObjectPtr convertToTrueOrFalse(RexxThreadContext *c, RexxObjectPtr obj);
extern char * strdupupr(const char *str);
extern char * strdupupr_nospace(const char *str);
extern char * strdup_nospace(const char *str);
extern char * strdup_2methodName(const char *str);
extern void checkModal(pCPlainBaseDialog previous, logical_t modeless);
extern pCPlainBaseDialog requiredDlgCSelf(RexxMethodContext *c, RexxObjectPtr self, oodClass_t type, size_t argPos, pCDialogControl *ppcdc);
extern oodClass_t oodClass(RexxMethodContext *, RexxObjectPtr, oodClass_t *, size_t);
extern DWORD oodGetSysErrCode(RexxThreadContext *);
extern void oodSetSysErrCode(RexxThreadContext *, DWORD);
extern void oodResetSysErrCode(RexxThreadContext *context);
extern bool oodGetWParam(RexxMethodContext *, RexxObjectPtr, WPARAM *, size_t, bool);
extern bool oodGetLParam(RexxMethodContext *, RexxObjectPtr, LPARAM *, size_t, bool);
extern bool oodObj2handle(RexxMethodContext *c, RexxObjectPtr obj, void **result, size_t argPos);
extern void *oodObj2pointer(RexxMethodContext *c, RexxObjectPtr obj);
extern int32_t checkID(RexxMethodContext *c, RexxObjectPtr rxID, RexxObjectPtr self);
extern int32_t idError(RexxMethodContext *c, RexxObjectPtr rxID);
extern int32_t oodGlobalID(RexxThreadContext *c, RexxObjectPtr id, size_t argPosID, bool strict);
extern int32_t oodResolveSymbolicID(RexxThreadContext *, RexxObjectPtr, RexxObjectPtr, int, size_t, bool);
extern bool oodSafeResolveID(int32_t *, RexxMethodContext *, RexxObjectPtr, RexxObjectPtr, int, size_t, bool);
extern int32_t resolveResourceID(RexxMethodContext *c, RexxObjectPtr rxID, RexxObjectPtr self);
extern int32_t resolveIconID(RexxMethodContext *c, RexxObjectPtr rxIconID, RexxObjectPtr self);
extern HICON getOORexxIcon(uint32_t id);
extern bool requiredOS(RexxMethodContext *context, const char *method, const char *osName, os_name_t os);
extern bool requiredOS(RexxMethodContext *context, os_name_t os, const char *msg, const char *osName);
extern bool requiredComCtl32Version(RexxMethodContext *context, const char *methodName, DWORD minimum);
extern bool requiredComCtl32Version(RexxMethodContext *context, DWORD minimum, const char *msg);
extern PPOINT rxGetPoint(RexxMethodContext *context, RexxObjectPtr p, size_t argPos);
extern RexxObjectPtr rxNewPoint(RexxThreadContext *c, long x, long y);
extern RexxObjectPtr rxNewPoint(RexxMethodContext *c, long x, long y);
extern PRECT rxGetRect(RexxMethodContext *context, RexxObjectPtr r, size_t argPos);
extern RexxObjectPtr rxNewRect(RexxMethodContext *context, long l, long t, long r, long b);
extern RexxObjectPtr rxNewRect(RexxThreadContext *context, PRECT r);
extern RexxObjectPtr rxNewRect(RexxMethodContext *context, PRECT r);
extern PSIZE rxGetSize(RexxMethodContext *context, RexxObjectPtr s, size_t argPos);
extern RexxObjectPtr rxNewSize(RexxThreadContext *c, long cx, long cy);
extern RexxObjectPtr rxNewSize(RexxMethodContext *c, long cx, long cy);
extern bool rxGetWindowText(RexxMethodContext *c, HWND hwnd, RexxStringObject *pStringObj);
extern bool rxDirectoryFromArray(RexxMethodContext *c, RexxArrayObject a, size_t index, RexxDirectoryObject *d, size_t argPos);
extern bool rxLogicalFromDirectory(RexxMethodContext *, RexxDirectoryObject, CSTRING, BOOL *, int, bool);
extern bool rxNumberFromDirectory(RexxMethodContext *, RexxDirectoryObject, CSTRING, uint32_t *, int, bool);
extern bool rxIntFromDirectory(RexxMethodContext *, RexxDirectoryObject, CSTRING, int *, int, bool);
extern int putUnicodeText(LPWORD dest, const char *text);
extern LPWSTR ansi2unicode(LPCSTR str);
extern RexxStringObject unicode2string(RexxMethodContext *c, PWSTR wstr);
extern char * unicode2ansi(PWSTR wstr);
extern RexxObjectPtr setWindowStyle(RexxMethodContext *c, HWND hwnd, uint32_t style);
extern int getKeywordValue(String2Int *cMap, const char * str);
extern bool goodMinMaxArgs(RexxMethodContext *c, RexxArrayObject args, size_t min, size_t max, size_t *arraySize);
extern bool getRectFromArglist(RexxMethodContext *, RexxArrayObject, PRECT, bool, int, int, size_t *, size_t *);
extern bool getPointFromArglist(RexxMethodContext *, RexxArrayObject, PPOINT, int, int, size_t *, size_t *);
// These functions are defined in oodUser.cpp.
extern bool getCategoryHDlg(RexxMethodContext *, RexxObjectPtr, uint32_t *, HWND *, int);
extern uint32_t getCategoryNumber(RexxMethodContext *, RexxObjectPtr);
// These functions are defined in oodUtilities.cpp
extern RexxObjectPtr makeDayStateBuffer(RexxMethodContext *c, RexxArrayObject list, size_t count, LPMONTHDAYSTATE *ppmds);
extern RexxObjectPtr makeQuickDayStateBuffer(RexxMethodContext *c, RexxObjectPtr _ds1, RexxObjectPtr _ds2, RexxObjectPtr _ds3, LPMONTHDAYSTATE *ppmds);
extern RexxObjectPtr quickDayStateBuffer(RexxMethodContext *c, uint32_t ds1, uint32_t ds2, uint32_t ds3, LPMONTHDAYSTATE *ppmds);
extern void putDefaultSymbols(RexxMethodContext *c, RexxDirectoryObject constDir);
// These functions are defined in ooDialog.cpp
extern bool initWindowBase(RexxMethodContext *c, HWND hwndObj, RexxObjectPtr self, pCWindowBase *ppCWB);
extern void setDlgHandle(pCPlainBaseDialog pcpbd);
extern RexxObjectPtr oodSetForegroundWindow(RexxMethodContext *c, HWND hwnd);
extern RexxObjectPtr oodGetFocus(RexxMethodContext *c, HWND hDlg);
extern RexxObjectPtr sendWinMsgGeneric(RexxMethodContext *, HWND, CSTRING, RexxObjectPtr, RexxObjectPtr, size_t, bool);
extern bool loadResourceDLL(pCPlainBaseDialog pcpbd, CSTRING library);
extern void ensureFinished(pCPlainBaseDialog pcpbd, RexxThreadContext *c, RexxObjectPtr abnormal);
// These functions are defined in oodBaseDialog.cpp
extern bool initWindowExtensions(RexxMethodContext *, RexxObjectPtr, HWND, pCWindowBase, pCPlainBaseDialog);
extern bool validControlDlg(RexxMethodContext *c, pCPlainBaseDialog pcpbd);
extern bool processOwnedDialog(RexxMethodContext *c, pCPlainBaseDialog pcpbd);
extern void setFontAttrib(RexxThreadContext *c, pCPlainBaseDialog pcpbd);
extern void customDrawCheckIDs(pCPlainBaseDialog pcpbd);
// These functions are defined in oodPropertySheet.cpp
extern void abortPropertySheet(pCPropertySheetDialog pcpsd, HWND hDlg, DlgProcErrType t);
extern void abortPropertySheetPage(pCPropertySheetPage page, HWND hDlg, DlgProcErrType t);
extern void abortOwnedDlg(pCPlainBaseDialog pcpbd, HWND hDlg, DlgProcErrType t);
// This function is defined in oodControl.cpp. TODO should be in
// oodControl.hpp, but needed by oodCommon.cpp, need to straighten out all
// theses extern declarations.
extern const char *controlType2controlName(oodControl_t control);
// These functions are defined in oodViewControls.cpp
extern bool isInReportView(HWND hList);
// Shared button stuff.
typedef enum {push, check, radio, group, owner, notButton} BUTTONTYPE, *PBUTTONTYPE;
typedef enum {def, autoCheck, threeState, autoThreeState, noSubtype } BUTTONSUBTYPE, *PBUTTONSUBTYPE;
extern BUTTONTYPE getButtonInfo(HWND, PBUTTONSUBTYPE, DWORD *);
inline int32_t oodGlobalID(RexxMethodContext *c, RexxObjectPtr id, size_t argPosID, bool strict)
{
return oodGlobalID(c->threadContext, id, argPosID, strict);
}
inline int32_t oodResolveSymbolicID(RexxMethodContext *c, RexxObjectPtr oodObj, RexxObjectPtr id,
int posObj, size_t posID, bool strict)
{
return oodResolveSymbolicID(c->threadContext, oodObj, id, posObj, posID, strict);
}
inline void safeLocalFree(void *p)
{
if (p != NULL)
{
LocalFree(p);
}
}
inline void safeFree(void *p)
{
if (p != NULL)
{
free(p);
}
}
inline void safeDeleteObject(HANDLE h)
{
if (h != NULL)
{
DeleteObject(h);
}
}
inline void oodSetSysErrCode(RexxThreadContext *context)
{
oodSetSysErrCode(context, GetLastError());
}
inline LPWORD lpwAlign(LPWORD lpIn)
{
ULONG_PTR ul = (ULONG_PTR)lpIn;
ul +=3;
ul >>=2;
ul <<=2;
return (LPWORD)ul;
}
/**
* Returns the first character of the message name that invoked the current
* method.
*
* @param context The method context.
*
* @return The first charactere of the message name.
*/
inline char msgAbbrev(RexxMethodContext *context)
{
return *(context->GetMessageName());
}
/**
* Checks that the argument could be construed as 'true'. This would be 1 or
* yes, but for historical reasons the German ja must also be included.
*
* This will also work for an optional arg to an API method. I.e., if s is
* null, false is returned.
*
* @param s The string to check.
*
* @return bool
*/
inline bool isYes(const char * s)
{
if ( s == NULL || strlen(s) == 0 )
{
return false;
}
char c = toupper(s[0]);
return ( c == 'J' || c =='Y' || c == '1' );
}
inline bool isEmptyString(const char * s)
{
return s != NULL && *s == '\0';
}
inline RexxObjectPtr convertToTrueOrFalse(RexxMethodContext *c, RexxObjectPtr obj)
{
return convertToTrueOrFalse(c->threadContext, obj);
}
inline const char *comctl32VersionName(DWORD id)
{
return comctl32VersionPart(id, COMCTL32_FULL_PART);
}
inline bool hasStyle(HWND hwnd, LONG style)
{
if ( (GetWindowLong(hwnd, GWL_STYLE) & style) || (GetWindowLong(hwnd, GWL_EXSTYLE) & style) )
{
return true;
}
return false;
}
/**
* Determines if the currently executing thread is the same thread as the
* dialog's message processing loop thread.
*
* @param pcpbd
* @return bool
*/
inline bool isDlgThread(pCPlainBaseDialog pcpbd)
{
return pcpbd->dlgProcThreadID == GetCurrentThreadId();
}
/**
* Searches the tool tip table for the tool tip matching id.
*
* @param pcpbd
* @param id
*
* @return a pointer to the tool tip entry on success, null if there is no such
* tool tip.
*/
inline PTOOLTIPTABLEENTRY findToolTipForID(pCPlainBaseDialog pcpbd, uint32_t id)
{
for ( register size_t i = 0; i < pcpbd->TTT_nextIndex; i++ )
{
if ( pcpbd->ToolTipTab[i].id == id )
{
return &pcpbd->ToolTipTab[i];
}
}
return NULL;
}
extern void ooDialogInternalException(RexxMethodContext *, char *, int, char *, char *);
extern void systemServiceExceptionCode(RexxThreadContext *context, const char *msg, const char *arg1);
extern void systemServiceExceptionComCode(RexxThreadContext *context, const char *msg, const char *arg1, HRESULT hr);
extern RexxObjectPtr invalidCategoryPageException(RexxMethodContext *c, int, int);
extern RexxObjectPtr noSuchPageException(RexxMethodContext *c, RexxObjectPtr page, size_t pos);
extern RexxObjectPtr noWindowsPageException(RexxMethodContext *c, size_t pageID, size_t pos);
extern RexxObjectPtr noSuchPageException(RexxMethodContext *c, int32_t id, uint32_t index);
extern void *noWindowsPageDlgException(RexxMethodContext *c, size_t pos);
extern RexxObjectPtr noSuchControlException(RexxMethodContext *c, int32_t id, RexxObjectPtr rxDlg, size_t pos);
extern RexxObjectPtr controlNotSupportedException(RexxMethodContext *c, RexxObjectPtr rxID, RexxObjectPtr rxDlg, size_t pos, RexxStringObject controlName);
extern void *wrongClassReplyException(RexxThreadContext *c, const char *mName, const char *n);
extern void *wrongReplyListException(RexxThreadContext *c, const char *mName, const char *list, RexxObjectPtr actual);
extern void *wrongReplyMsgException(RexxThreadContext *c, const char *mName, const char *msg);
extern void *wrongReplyRangeException(RexxThreadContext *c, const char *mName, int32_t min, int32_t max, RexxObjectPtr actual);
extern void *wrongReplyNotBooleanException(RexxThreadContext *c, const char *mName, RexxObjectPtr actual);
extern void controlFailedException(RexxThreadContext *, CSTRING, CSTRING, CSTRING);
extern void wrongWindowStyleException(RexxMethodContext *c, CSTRING, CSTRING);
extern void bitmapTypeMismatchException(RexxMethodContext *c, CSTRING orig, CSTRING found, size_t pos);
extern void customDrawMismatchException(RexxThreadContext *c, uint32_t id, oodControl_t type);
extern RexxObjectPtr methodCanNotBeInvokedException(RexxMethodContext *c, CSTRING methodName, RexxObjectPtr rxDlg, CSTRING msg);
extern RexxObjectPtr methodCanNotBeInvokedException(RexxMethodContext *c, CSTRING methodName, CSTRING msg, RexxObjectPtr rxDlg);
extern RexxObjectPtr invalidAttributeException(RexxMethodContext *c, RexxObjectPtr rxDlg);
/**
* 93.900
* Error 93 - Incorrect call to method
* The specified method, built-in function, or external routine exists,
* but you used it incorrectly.
*
* The "methName" method can not be invoked on "objectName" when the "msg"
*
* The connectEdit method can not be invoked on a StyleDlg when the Windows
* dialog does not exist.
*
* @param c
* @param rxDlg
* @param msg
*/
inline RexxObjectPtr methodCanNotBeInvokedException(RexxMethodContext *c, RexxObjectPtr rxDlg, CSTRING msg)
{
return methodCanNotBeInvokedException(c, c->GetMessageName(), msg, rxDlg);
}
/**
* 93.900
* Error 93 - Incorrect call to method
* The specified method, built-in function, or external routine exists,
* but you used it incorrectly.
*
* The "methName" method can not be invoked on "objectName" when the Windows
* dialog does not exist.
*
* The connectEdit method can not be invoked on a StyleDlg when the Windows
* dialog does not exist.
*
* @param c
* @param rxDlg
*/
inline RexxObjectPtr noWindowsDialogException(RexxMethodContext *c, RexxObjectPtr rxDlg)
{
return methodCanNotBeInvokedException(c, rxDlg, "Windows dialog does not exist");
}
/**
* 93.900
* Error 93 - Incorrect call to method
* The specified method, built-in function, or external routine exists,
* but you used it incorrectly.
*
* The "methName" method can not be invoked on "objectName" when the parent
* Windows dialog does not exist.
*
* The STARTDIALOG method can not be invoked on an AddressDlg when the parent
* Windows dialog does not exist.
*
* @param c
* @param rxDlg
*/
inline RexxObjectPtr noParentWindowsDialogException(RexxMethodContext *c, RexxObjectPtr rxDlg)
{
return methodCanNotBeInvokedException(c, rxDlg, "parent Windows dialog does not exist");
}
/**
* 93.900
* Error 93 - Incorrect call to method
* The specified method, built-in function, or external routine exists,
* but you used it incorrectly.
*
* The "methName" method can not be invoked on "objectName" when the parent
* Rexx dialog has not been assigned.
*
* The connectEdit method can not be invoked on a StyleDlg when the parent
* Rexx dialog has not been assigned.
*
* @param c
* @param rxDlg
*/
inline RexxObjectPtr noOwnerRexxDialogException(RexxMethodContext *c, RexxObjectPtr rxDlg)
{
return methodCanNotBeInvokedException(c, rxDlg, "parent Rexx dialog has not been assigned");
}
/**
* 93.900
* Error 93 - Incorrect call to method
* The specified method, built-in function, or external routine exists,
* but you used it incorrectly.
*
* The "methName" method can not be invoked on "objectName" when the window
* handle is not valid.
*
* The getMaxSelection method can not be invoked on a MonthCalendar when the
* window handle is not valid.
*
* @param c
* @param rxObj
*/
inline RexxObjectPtr invalidWindowException(RexxMethodContext *c, RexxObjectPtr rxObj)
{
return methodCanNotBeInvokedException(c, rxObj, "window handle is not valid");
}
/**
* 93.900
* Error 93 - Incorrect call to method
* The specified method, built-in function, or external routine exists,
* but you used it incorrectly.
*
* The "methName" method can not be invoked on "objectName" when the tool tip
* control does not exist.
*
* The connectToolTipEvent method can not be invoked on a SimpleDialog when
* the tool tip control does not exist.
*
* @param c
* @param rxObj
*/
inline RexxObjectPtr noToolTipException(RexxMethodContext *c, RexxObjectPtr rxObj)
{
return methodCanNotBeInvokedException(c, rxObj, "tool tip control does not exist");
}
/**
* Ensures that a dialog CSelf pointer is not null. This can happen if the user
* invokes a method in a dialog subclass before invoking the superclass init()
* method.
*
* Unfortunately users do this. ;-( Before the conversion to the C++ API,
* things were not working as the user expected, but no "real bad" things
* happened. Now, this causes a null point derefernce unless we check first.
*
* @param c Method context we are operating.
* @param pCSelf CSelf pointer for the dialog object.
*
* @return The CSelf pointer cast to a pCPlainBaseDialog, or null if pCSelf is
* null.
*
* @note The whole point of this is to raise the exception if pCSelf is null.
*/
static inline pCPlainBaseDialog getPBDCSelf(RexxMethodContext *c, void * pCSelf)
{
if ( pCSelf == NULL )
{
baseClassInitializationException(c);
}
return (pCPlainBaseDialog)pCSelf;
}
/**
* Retrieves the PlainBaseDialog class CSelf pointer.
*
* @param c Method contex we are operating in.
*
* @return The pointer to the CPlainBaseDialogClass struct.
*/
inline pCPlainBaseDialogClass dlgToClassCSelf(RexxMethodContext *c)
{
return (pCPlainBaseDialogClass)c->ObjectToCSelf(ThePlainBaseDialogClass);
}
/**
* Retrieves the CSelf pointer for a dialog object when the dialog object is not
* the direct object the method was invoked on. This performs a scoped CSelf
* lookup.
*
* @param c The method (or thread) context we are operating in.
* @param dlg The dialog object whose CSelf pointer is needed.
*
* @return A pointer to the CSelf of the dlg object.
*
* @assumes The caller has ensured dlg is in fact a ooDialog Rexx dialog
* object.
*/
inline pCPlainBaseDialog dlgToCSelf(RexxMethodContext *c, RexxObjectPtr dlg)
{
return (pCPlainBaseDialog)c->ObjectToCSelf(dlg, ThePlainBaseDialogClass);
}
inline pCPlainBaseDialog dlgToCSelf(RexxThreadContext *c, RexxObjectPtr dlg)
{
return (pCPlainBaseDialog)c->ObjectToCSelf(dlg, ThePlainBaseDialogClass);
}
/**
* Retrieves the PropertySheetPage CSelf pointer for a dialog object when the
* dialog object is not the direct object the method was invoked on. This
* performs a scoped CSelf lookup.
*
* @param c The method context we are operating in.
* @param dlg The dialog object whose PropertySheetPage CSelf pointer is
* needed.
*
* @return A pointer to the PropertySheetPage CSelf of the dlg object.
*
* @assumes The caller has ensured dlg is in fact a ooDialog Rexx
* PropertySheetPage dialog object.
*/
inline pCPropertySheetPage dlgToPSPCSelf(RexxMethodContext *c, RexxObjectPtr dlg)
{
return (pCPropertySheetPage)c->ObjectToCSelf(dlg, ThePropertySheetPageClass);
}
/**
* Retrieves the ControlDialog CSelf pointer for a dialog object when the
* dialog object is not the direct object the method was invoked on. This
* performs a scoped CSelf lookup.
*
* @param c The method context we are operating in.
* @param dlg The dialog object whose ControlDialog CSelf pointer is needed.
*
* @return A pointer to the ControlDialog CSelf of the dlg object.
*
* @assumes The caller has ensured dlg is in fact a ooDialog Rexx ControlDialog
* dialog object.
*/
inline pCControlDialog dlgToCDCSelf(RexxMethodContext *c, RexxObjectPtr dlg)
{
return (pCControlDialog)c->ObjectToCSelf(dlg, TheControlDialogClass);
}
/**
* Retrieves the window handle for a property sheet page from an ooDialog dialog
* object which was not the direct object the method was invoked on. This
* performs a scoped CSelf lookup.
*
* @param c The method context we are operating in.
* @param dlg The dialog object whose window handle is needed.
*
* @return The window handle of the dialog. Note that this will be null if the
* underlying Windows dialog has not yet been created.
*
* @assumes The caller has ensured dlg is in fact a ooDialog Rexx property
* page object.
*/
inline HWND dlgToPSPHDlg(RexxMethodContext *c, RexxObjectPtr dlg)
{
pCPropertySheetPage pcpsp = dlgToPSPCSelf(c, dlg);
return pcpsp->hPage;
}
/**
* Retrieves the EventNotification CSelf from an ooDialog dialog object.
*
* @param c The method context we are operating in.
* @param dlg The dialog object whose EventNotification CSelf is needed.
*
* @return A pointer to CEventNotification struct for the dialog.
*
* @assumes The caller has ensured dlg is in fact a ooDialog Rexx dialog
* object.
*/
inline pCEventNotification dlgToEventNotificationCSelf(RexxMethodContext *c, RexxObjectPtr dlg)
{
pCPlainBaseDialog pcpbd = dlgToCSelf(c, dlg);
return pcpbd->enCSelf;
}
/**
* Retrieves the dialog window handle from an ooDialog dialog object.
*
* @param c The method context we are operating in.
* @param dlg The dialog object whose window handle is needed.
*
* @return The window handle of the dialog. Note that this will be null if the
* underlying Windows dialog has not yet been created.
*
* @assumes The caller has ensured dlg is in fact a ooDialog Rexx dialog
* object.
*/
inline HWND dlgToHDlg(RexxMethodContext *c, RexxObjectPtr dlg)
{
pCPlainBaseDialog pcpbd = dlgToCSelf(c, dlg);
return pcpbd->hDlg;
}
/**
* Retrieves the CSelf pointer for a dialog control object when the control
* object is not the direct object the method was invoked on. This performs a
* scoped CSelf lookup.
*
* @param c The method context we are operating in.
* @param ctrl The control object whose CSelf pointer is needed.
*
* @return A pointer to the CSelf of the control object.
*
* @assumes The caller has ensured ctrl is in fact a ooDialog Rexx dialog
* control object.
*/
inline pCDialogControl controlToCSelf(RexxThreadContext *c, RexxObjectPtr ctrl)
{
return (pCDialogControl)c->ObjectToCSelf(ctrl, TheDialogControlClass);
}
inline pCDialogControl controlToCSelf(RexxMethodContext *c, RexxObjectPtr ctrl)
{
return controlToCSelf(c->threadContext, ctrl);
}
/**
* Retrieves the window handle for a dialog control object when the control
* object is not the direct object the method was invoked on. This performs a
* scoped CSelf lookup.
*
* @param c The method context we are operating in.
* @param ctrl The control object whose window handle is needed.
*
* @return The window handle of the dialog control.
*
* @assumes The caller has ensured ctrl is in fact a ooDialog Rexx dialog
* control object.
*/
inline HWND controlToHCtrl(RexxMethodContext *c, RexxObjectPtr ctrl)
{
pCDialogControl pcdc = (pCDialogControl)c->ObjectToCSelf(ctrl, TheDialogControlClass);
return pcdc->hCtrl;
}
/**
* Convenience function to put up an error message box.
*
* @param pszMsg The message.
* @param pszTitle The title of for the message box.
*/
inline void internalErrorMsgBox(CSTRING pszMsg, CSTRING pszTitle)
{
MessageBox(0, pszMsg, pszTitle, MB_OK | MB_ICONHAND | MB_SETFOREGROUND | MB_TASKMODAL);
}
#endif