RexxMethod2(logical_t, dlgctrl_hasKeyPressConnection, OPTIONAL_CSTRING, methodName, CSELF, pCSelf) { if ( ComCtl32Version < COMCTL32_6_0 ) { return FALSE; } pCDialogControl pcdc = (pCDialogControl)pCSelf; SUBCLASSDATA *pData = NULL; if ( ! GetWindowSubclass(pcdc->hCtrl, KeyPressSubclassProc, pcdc->id, (DWORD_PTR *)&pData) ) { return FALSE; } if ( pData == NULL ) { return FALSE; } if ( argumentOmitted(1) ) { return TRUE; } char *tmpName = strdupupr(methodName); if ( tmpName == NULL ) { outOfMemoryException(context->threadContext); return FALSE; } BOOL exists = (seekKeyPressMethod((KEYPRESSDATA *)pData->pData, tmpName) > 0); free(tmpName); return exists; }
/** MessageDialog() * * * @param text * @param hwnd Handle of owner window. If the user specifies 0 we do not use * an owner window. If the user omits hwnd, then we try the to * find and use the topmost dialog. * * * @note Sets the .SystemErrorCode. * */ RexxRoutine6(int, messageDialog_rtn, CSTRING, text, OPTIONAL_CSTRING, hwnd, OPTIONAL_CSTRING, _title, OPTIONAL_CSTRING, button, OPTIONAL_CSTRING, icon, OPTIONAL_CSTRING, miscStyles) { oodResetSysErrCode(context->threadContext); int result = -1; char *uprButton = NULL; char *uprIcon = NULL; char *uprMiscStyles = NULL; HWND hwndOwner = (HWND)string2pointer(hwnd); if ( hwndOwner == NULL ) { if ( argumentOmitted(2) && TopDlg != NULL && TopDlg->onTheTop ) { hwndOwner = TopDlg->hDlg; } } CSTRING title = "ooDialog Application Message"; if ( argumentExists(3) ) { title = _title; } // Defaults. These values are all 0. uint32_t flags = MB_OK | MB_DEFBUTTON1 | MB_APPLMODAL; uint32_t flag; if ( argumentExists(4) ) { uprButton = strdupupr(button); if ( uprButton == NULL ) { outOfMemoryException(context->threadContext); goto done_out; } flag = winKeyword2ID(uprButton, context->threadContext, 4, "MessageDialog button keyword"); if ( flag == (int)-1 ) { goto done_out; } flags |= flag; } // There is no default for the icon, if omitted there is no icon. if ( argumentExists(5) ) { uprIcon = strdupupr(icon); if ( uprIcon == NULL ) { outOfMemoryException(context->threadContext); goto done_out; } flag = winKeyword2ID(uprIcon, context->threadContext, 5, "MessageDialog icon keyword"); if ( flag == (int)-1 ) { goto done_out; } flags |= flag; } if ( argumentExists(6) ) { uprMiscStyles = strdupupr(miscStyles); if ( uprMiscStyles == NULL ) { outOfMemoryException(context->threadContext); goto done_out; } flag = getMiscMBStyle(uprMiscStyles, context, 6, "MessageDialog style keyword"); if ( flag == (int)-1 ) { goto done_out; } flags |= flag; } result = MessageBox(hwndOwner, text, title, flags); if ( result == 0 ) { oodSetSysErrCode(context->threadContext); } done_out: safeFree(uprButton); safeFree(uprIcon); safeFree(uprMiscStyles); return result; }
RexxMethod2(int32_t, dlgctrl_disconnectKeyPress, OPTIONAL_CSTRING, methodName, CSELF, pCSelf) { char *tmpName = NULL; keyPressErr_t result = winAPIErr; if ( ! requiredComCtl32Version(context, context->GetMessageName(), COMCTL32_6_0) ) { goto done_out; } pCDialogControl pcdc = (pCDialogControl)pCSelf; SUBCLASSDATA *pSubclassData = NULL; GetWindowSubclass(pcdc->hCtrl, KeyPressSubclassProc, pcdc->id, (DWORD_PTR *)&pSubclassData); // If pSubclassData is not null, the subclass is still installed, otherwise // the subclass has already been removed, (or never existed.) if ( pSubclassData != NULL ) { // If no method name, remove the whole thing. if ( argumentOmitted(1) ) { result = (removeKeyPressSubclass(pSubclassData, pcdc->hDlg, pcdc->id) ? noErr : winAPIErr); goto done_out; } // Have a method name, just remove that method from the mapping. tmpName = strdupupr(methodName); if ( tmpName == NULL ) { result = memoryErr; goto done_out; } KEYPRESSDATA *pKeyPressData = (KEYPRESSDATA *)pSubclassData->pData; uint32_t index = seekKeyPressMethod(pKeyPressData, tmpName); if ( index == 0 ) { result = nameErr; goto done_out; } // If only 1 method left, remove the subclass entirely. Otherwise, // remove the subclass, fix up the subclass data block, then reinstall // the subclass. BOOL success = FALSE; if ( pKeyPressData->usedMethods == 1 ) { success = removeKeyPressSubclass(pSubclassData, pcdc->hDlg, pcdc->id); } else { if ( SendMessage(pcdc->hDlg, WM_USER_SUBCLASS_REMOVE, (WPARAM)KeyPressSubclassProc, (LPARAM)pcdc->id) ) { removeKeyPressMethod(pKeyPressData, index); success = (BOOL)SendMessage(pcdc->hDlg, WM_USER_SUBCLASS, (WPARAM)KeyPressSubclassProc, (LPARAM)pSubclassData); // If not success, then the subclass procedure is no longer // installed, (even though it was originally,) and the memory // will never be cleaned up, so clean it up now. if ( ! success ) { freeKeyPressData(pSubclassData); } } } result = (success ? noErr : winAPIErr); } done_out: return -(int32_t)result; }