virtual void OnDestroy() { xmlDestroyNode(m_agentRegIqNode); JabberFormDestroyUI(GetDlgItem(m_hwnd, IDC_FRAME)); m_proto->m_hwndAgentRegInput = NULL; EnableWindow(GetParent(m_hwnd), TRUE); SetActiveWindow(GetParent(m_hwnd)); }
static INT_PTR CALLBACK JabberSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { JabberSearchData* dat = ( JabberSearchData* )GetWindowLongPtr( hwndDlg, GWLP_USERDATA ); switch ( msg ) { case WM_INITDIALOG: { TranslateDialogDefault(hwndDlg); dat = ( JabberSearchData * )mir_alloc( sizeof( JabberSearchData )); memset( dat, 0, sizeof( JabberSearchData )); dat->ppro = ( CJabberProto* )lParam; SetWindowLongPtr( hwndDlg, GWLP_USERDATA, (LONG_PTR)dat ); /* Server Combo box */ char szServerName[100]; if ( dat->ppro->JGetStaticString( "Jud", NULL, szServerName, sizeof szServerName )) strcpy( szServerName, "users.jabber.org" ); SetDlgItemTextA(hwndDlg,IDC_SERVER,szServerName); SendDlgItemMessageA(hwndDlg,IDC_SERVER,CB_ADDSTRING,0,(LPARAM)szServerName); //TO DO: Add Transports here int i, transpCount = dat->ppro->m_lstTransports.getCount(); for ( i=0; i < transpCount; i++ ) { TCHAR* szTransp = dat->ppro->m_lstTransports[i]; if ( szTransp ) JabberSearchAddUrlToRecentCombo(hwndDlg, szTransp ); } DBVARIANT dbv; char key[30]; for ( i=0; i < 10; i++ ) { sprintf(key,"RecentlySearched_%d",i); if ( !dat->ppro->JGetStringT( NULL, key, &dbv )) { JabberSearchAddUrlToRecentCombo(hwndDlg, dbv.ptszVal ); JFreeVariant( &dbv ); } } //TO DO: Add 4 recently used dat->lastRequestIq = dat->ppro->SearchRenewFields(hwndDlg,dat); } return TRUE; case WM_COMMAND: if ( LOWORD(wParam) == IDC_SERVER ) { switch ( HIWORD( wParam )) { case CBN_SETFOCUS: PostMessage(GetParent(hwndDlg),WM_COMMAND, MAKEWPARAM(0,EN_SETFOCUS), (LPARAM)hwndDlg); return TRUE; case CBN_EDITCHANGE: EnableWindow(GetDlgItem(hwndDlg, IDC_GO),TRUE); return TRUE; case CBN_EDITUPDATE: JabberSearchFreeData(hwndDlg, dat); EnableWindow(GetDlgItem(hwndDlg, IDC_GO),TRUE); return TRUE; case CBN_SELENDOK: EnableWindow(GetDlgItem(hwndDlg, IDC_GO),TRUE); PostMessage(hwndDlg,WM_COMMAND,MAKEWPARAM(IDC_GO,BN_CLICKED),0); return TRUE; } } else if ( LOWORD(wParam) == IDC_GO && HIWORD(wParam) == BN_CLICKED ) { dat->ppro->SearchRenewFields( hwndDlg, dat ); return TRUE; } break; case WM_SIZE: { //Resize IDC_FRAME to take full size RECT rcForm; GetWindowRect(hwndDlg, &rcForm); RECT rcFrame; GetWindowRect( GetDlgItem(hwndDlg, IDC_FRAME), &rcFrame ); rcFrame.bottom = rcForm.bottom; SetWindowPos(GetDlgItem(hwndDlg,IDC_FRAME),NULL,0,0,rcFrame.right-rcFrame.left,rcFrame.bottom-rcFrame.top,SWP_NOZORDER|SWP_NOMOVE); GetWindowRect(GetDlgItem(hwndDlg,IDC_VSCROLL), &rcForm); SetWindowPos(GetDlgItem(hwndDlg,IDC_VSCROLL),NULL,0,0,rcForm.right-rcForm.left,rcFrame.bottom-rcFrame.top,SWP_NOZORDER|SWP_NOMOVE); JabberSearchRefreshFrameScroll(hwndDlg, dat); } return TRUE; case WM_USER+11: { dat->fSearchRequestIsXForm=TRUE; dat->xNode = ( HXML )wParam; JabberFormCreateUI( GetDlgItem(hwndDlg, IDC_FRAME), dat->xNode, &dat->CurrentHeight,TRUE); ShowWindow(GetDlgItem(hwndDlg, IDC_FRAME), SW_SHOW); dat->nJSInfCount=1; return TRUE; } case WM_USER+10: { Data* MyDat = ( Data* )lParam; if ( MyDat ) { dat->fSearchRequestIsXForm = ( BOOL )wParam; dat->CurrentHeight = JabberSearchAddField(hwndDlg,MyDat); mir_free( MyDat->Label ); mir_free( MyDat->Var ); mir_free( MyDat->defValue ); free( MyDat ); } else { JabberSearchRefreshFrameScroll(hwndDlg,dat); ScrollWindow( GetDlgItem( hwndDlg, IDC_FRAME ), 0, dat->curPos - 0, NULL, &( dat->frameRect )); SetScrollPos( GetDlgItem( hwndDlg, IDC_VSCROLL ), SB_CTL, 0, FALSE ); dat->curPos=0; } return TRUE; } case WM_MOUSEWHEEL: { int zDelta = GET_WHEEL_DELTA_WPARAM(wParam); if ( zDelta ) { int nScrollLines=0; SystemParametersInfo(SPI_GETWHEELSCROLLLINES,0,(void*)&nScrollLines,0); for (int i=0; i<(nScrollLines+1)/2; i++) SendMessage(hwndDlg,WM_VSCROLL, (zDelta<0)?SB_LINEDOWN:SB_LINEUP,0); } } return TRUE; case WM_VSCROLL: { int pos; if ( dat != NULL ) { pos = dat->curPos; switch ( LOWORD( wParam )) { case SB_LINEDOWN: pos += 10; break; case SB_LINEUP: pos -= 10; break; case SB_PAGEDOWN: pos += ( dat->CurrentHeight - 10 ); break; case SB_PAGEUP: pos -= ( dat->CurrentHeight - 10 ); break; case SB_THUMBTRACK: pos = HIWORD( wParam ); break; } if ( pos > ( dat->CurrentHeight - dat->frameHeight )) pos = dat->CurrentHeight - dat->frameHeight; if ( pos < 0 ) pos = 0; if ( dat->curPos != pos ) { ScrollWindow( GetDlgItem( hwndDlg, IDC_FRAME ), 0, dat->curPos - pos, NULL , &( dat->frameRect )); SetScrollPos( GetDlgItem( hwndDlg, IDC_VSCROLL ), SB_CTL, pos, TRUE ); RECT Invalid=dat->frameRect; if (dat->curPos - pos >0) Invalid.bottom=Invalid.top+(dat->curPos - pos); else Invalid.top=Invalid.bottom+(dat->curPos - pos); RedrawWindow(GetDlgItem( hwndDlg, IDC_FRAME ), NULL, NULL, RDW_UPDATENOW |RDW_ALLCHILDREN); dat->curPos = pos; } } } return TRUE; case WM_DESTROY: JabberSearchFreeData( hwndDlg, dat ); JabberFormDestroyUI( GetDlgItem( hwndDlg, IDC_FRAME )); mir_free( dat ); SetWindowLongPtr( hwndDlg, GWLP_USERDATA, 0 ); return TRUE; } return FALSE; }