void
ConnectionCommunity::OnTestConnection(HWND hwnd)
{
	UpdateWindow(hwnd);

	if(GetActiveWin())
		UpdateWindow(GetActiveWin()->m_pctabmodule->GetHwnd());		

	TestConnection(hwnd, wyTrue);
}
示例#2
0
//When a "Key_Down" on Html page
BOOL
OnKeyDown(KEY_PARAMS *params)   
{		
#ifndef COMMUNITY
	MDIWindow*      wnd;
	wyInt32			tabicon;
	TabDbSearch*    tabsearch = NULL;

    wnd = GetActiveWin();
    tabicon = wnd->m_pctabmodule->GetActiveTabImage();

	//Handle Database search tab, when press on Enter key
	if(tabicon == IDI_DATASEARCH)
	{	
        if(!(tabsearch = (TabDbSearch*)wnd->m_pctabmodule->GetActiveTabType()))
        {
            return FALSE;
        }

        if(params->cmd == KEY_DOWN && params->key_code == VK_RETURN)
		{
            if(tabsearch->OnEnterKey(params->target))
            {
                return TRUE;					
            }
		}	
	}
#endif
    return FALSE;
}
void
TableMakerAdvProperties::InitCollationCombo()
{
    MDIWindow   *wnd = GetActiveWin();
    wyString    query, collationstr;
    MYSQL_ROW   myrow;
    MYSQL_RES   *myres;
    wyInt32     index;

    HWND        hwndcombo = GetDlgItem(m_hwnd, IDC_TABCOLLATION);

    query.SetAs("show collation");
    myres = ExecuteAndGetResult(wnd, wnd->m_tunnel, &wnd->m_mysql, query);
    if(!myres)
    {
        ShowMySQLError(m_hwnd, wnd->m_tunnel, &wnd->m_mysql, query.GetString());
        return;
    }
    while(myrow = wnd->m_tunnel->mysql_fetch_row(myres))
    {
        collationstr.SetAs(myrow[0]);
        SendMessage(hwndcombo , CB_ADDSTRING, 0,(LPARAM)collationstr.GetAsWideChar());
    }
    if((index = SendMessage(hwndcombo , CB_ADDSTRING, 0,(LPARAM)TEXT(STR_DEFAULT))) != CB_ERR)
        index = SendMessage(hwndcombo, CB_SETCURSEL, index, (LPARAM)TEXT(STR_DEFAULT));
}
示例#4
0
wyBool 
BlobMgmt::Create(HWND hwndParent, PINSERTUPDATEBLOB pib, wyBool edit)
{
	wyInt32     ret;
    MDIWindow   *wnd = GetActiveWin();

	m_piub			=	pib;
	m_olddata		=	pib->m_data;
	m_olddatasize	=	pib->m_datasize;
	m_oldnull		=	pib->m_isnull;	
	m_newdata		=	pib->m_data;
	m_newdatasize	=	pib->m_datasize;
	m_edit          =	edit;
	m_hfont         =	NULL;
	m_isblob		=   pib->m_isblob;

	//Post 8.01F
	//RepaintTabModule();
    
    if(wnd)
        wnd->m_lastfocus = NULL;

	ret = DialogBoxParam(pGlobals->m_hinstance, MAKEINTRESOURCE(IDD_INSERTUPDATEBLOB), hwndParent, 
                                                BlobMgmt::DlgProc,(LPARAM)this);
	if(ret)
		return wyTrue;

    return wyFalse;
}
示例#5
0
void  
EndExecute(MDIWindow * wnd, HWND hwnd, EXECUTEOPTION opt)
{
    MDIWindow* currentwnd = GetActiveWin();
	wnd->SetExecuting(wyFalse);
	
	//DEBUG_LOG("EndExecute::stop_query");
	
	wnd->m_stopquery     =    0;
	
	wnd->EnableWindowOnQueryExecution(wyTrue);

	/* enable all the tool buttons */
    if(wnd->m_hwnd == currentwnd->m_hwnd)
    {
	    pGlobals->m_pcmainwin->EnableToolButtonsAndCombo( 
                                pGlobals->m_pcmainwin->m_hwndtool,
                                pGlobals->m_pcmainwin->m_hwndsecondtool,
                                pGlobals->m_pcmainwin->m_hwndtoolcombo, wyTrue, wyTrue);
        wnd->EnableToolOnNoQuery();
        /* replace the correct icon with stop icon */
	    OnExecuteOptn(opt, wyFalse);

	    /* change the cursor to arrow mode */
        SetCursor(LoadCursor(NULL, IDC_ARROW));
    }

	CustomTab_SetClosable(wnd->m_pctabmodule->m_hwnd, wyTrue, 1);
	/* no executeoption */
	wnd->m_execoption = INVALID;

	EnableWindow(hwnd, TRUE);
}
示例#6
0
// Wndproc for the tab control.
LRESULT
TableTabInterfaceTabMgmt::WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam, wyBool *pishandled)
{
    TableTabInterface           *ptabint = NULL;
    TableTabInterfaceTabMgmt    *pctabintmgmt = NULL;
	MDIWindow		            *wnd = GetActiveWin();
    
	*pishandled = wyFalse;
    
    if(wnd && (wnd->m_pctabmodule->GetActiveTabImage() == IDI_CREATETABLE || wnd->m_pctabmodule->GetActiveTabImage() == IDI_ALTERTABLE))
    {
        ptabint = (TableTabInterface*) wnd->m_pctabmodule->GetActiveTabType();
        pctabintmgmt = (TableTabInterfaceTabMgmt*) ptabint->m_ptabintmgmt;
    }
	else
		return 0;
    
    switch(message)
    {
    case WM_NOTIFY:
        {
            LPNMHDR lpnmhdr =(LPNMHDR)lparam;
            switch(lpnmhdr->code)
			{
				case CTCN_WMDESTROY:
                    pctabintmgmt->m_hwnd = NULL;
                    break;
			}
        }
        break;
    }
    return 0;    
}
wyBool 
ImportBatch::GetCurDatabase()
{
	wyInt32			ret;
    wyString        query;
	MYSQL_RES*		myres;
	MYSQL_ROW		myrow;
	wyString		myrowstr;
	MDIWindow		*wnd = GetActiveWin();
	wyBool			ismysql41 = wnd->m_ismysql41;

	query.Sprintf("select database()");

	wnd->SetThreadBusy(wyTrue);
	ret = my_query(wnd, m_tunnel, m_umysql, query.GetString(), query.GetLength());
	wnd->SetThreadBusy(wyFalse);
	if(ret)
	{
		ShowMySQLError(m_hwnd, m_tunnel, m_umysql, query.GetString());
		return wyFalse;
	}

	myres	=	m_tunnel->mysql_store_result(*m_umysql, false, false, GetActiveWin());
	if(!myres)
	{
		ShowMySQLError(m_hwnd, m_tunnel, m_umysql, query.GetString());
		return wyFalse;
	}

	myrow	=	m_tunnel->mysql_fetch_row(myres);
	if(myrow[0])
    {
		myrowstr.SetAs(myrow[0], ismysql41);
		strncpy(m_curdb, myrowstr.GetString(), myrowstr.GetLength());
    }
    else 
		m_curdb[0] = NULL;
	if( strlen(m_curdb) == 0)
		strcpy(m_curdb, "<None>");

        myrowstr.SetAs(m_curdb);
	SendMessage(GetDlgItem(m_hwnd, IDC_CURDATABASE), WM_SETTEXT, 0, (LPARAM)myrowstr.GetAsWideChar()); 		
	
	m_tunnel->mysql_free_result(myres);	

	return wyTrue;
}
/*Importing process
Also if select a db in OB and use 'Restore from SQL dump' warning pops up
*/
void 
ImportBatch::ImportDump()
{
	MDIWindow *wnd;
	HTREEITEM	hitem = NULL;
	wyString	msg, dbname;
	wyInt32		ret = 0;

	if((SendMessage(m_hwndedit, WM_GETTEXTLENGTH, 0, 0)) > 0)
    {
		VERIFY(wnd = GetActiveWin());

		//Check whether 'Restore from SQL dump' used after selecting a db in OB
		if(m_importing == wyFalse && wnd && wnd->m_pcqueryobject && wnd->m_pcqueryobject->GetSelectionImage() == NDATABASE)
		{
			hitem = wnd->m_pcqueryobject->GetDatabaseNode();
			wnd->m_pcqueryobject->GetDatabaseName(hitem);

			dbname.SetAs(wnd->m_pcqueryobject->m_seldatabase);
		    
			//warning shows when restore from sql dump does database(to avoid confusion of USE db in dump)
			if(dbname.GetLength())
			{
				msg.Sprintf(_("The current database context is `%s`. SQL statements in the file will be executed here, unless one or more USE statement(s) specifying another database context is in the file. Do you want to continue?"),
								dbname.GetString()); 

				ret = MessageBox(wnd->m_hwnd, msg.GetAsWideChar(),pGlobals->m_appname.GetAsWideChar(), MB_ICONQUESTION | MB_YESNO);
				if(ret != IDYES)
					return;
			}
		}
		
		if(m_importing) 
        {
			/* behave as if the stop has been pushed */
//			DEBUG_LOG("stopping query");
			m_stopimport = wyTrue;
		} 
        else 
        {
//			DEBUG_LOG("executing import");
			VERIFY(wyFalse == m_importing);
			SetCursor(LoadCursor(NULL, IDC_WAIT));
			ExecuteBatch();
			SetCursor(LoadCursor(NULL, IDC_ARROW));
		}
	}
	else
		yog_message(m_hwnd, _(L"Please enter a filename"), pGlobals->m_appname.GetAsWideChar(), MB_OK | MB_ICONINFORMATION);

	return;
}
示例#9
0
wyBool
EditorBase::ShowResultWindow()
{
	wyInt32	      lstyle;
	wyUInt32	  menustate;
	wyUInt32	  ret;
	HMENU	      hmenu, hsubmenu;

	TabMgmt				*ptabmgmt;	
	TabEditorSplitter	*ptesplitter;
	MDIWindow	*	pCQueryWnd =(MDIWindow*)GetActiveWin();

	if (pCQueryWnd->GetActiveTabEditor()->m_isresultwnd)
		return wyTrue;

	VERIFY(hmenu = GetMenu(pGlobals->m_pcmainwin->m_hwndmain));

	lstyle = GetWindowLongPtr(pCQueryWnd->m_hwnd, GWL_STYLE);

	if ((lstyle & WS_MAXIMIZE) && wyTheme::IsSysmenuEnabled(pCQueryWnd->m_hwnd))
		VERIFY(hsubmenu = GetSubMenu(hmenu, 2));
	else
		VERIFY(hsubmenu = GetSubMenu(hmenu, 1));

	menustate = GetMenuState(hsubmenu, IDC_EDIT_SHOWRESULT, MF_BYCOMMAND);

	ret = CheckMenuItem(hsubmenu, IDC_EDIT_SHOWRESULT, MF_BYCOMMAND | MF_UNCHECKED);
	pCQueryWnd->GetActiveTabEditor()->m_isresultwnd = wyTrue;

	ptesplitter = pCQueryWnd->GetActiveTabEditor()->m_pcetsplitter;
	
	if(ptesplitter->m_leftortoppercent == ptesplitter->m_lasttoppercent && 
           ptesplitter->m_leftortoppercent == 100 && 
           ptesplitter->m_lasttoppercent == 100)
        {
            ptesplitter->m_lasttoppercent = 50;
            ptesplitter->m_leftortoppercent = ptesplitter->m_lasttoppercent;
        }
		else
            ptesplitter->m_leftortoppercent = ptesplitter->m_lasttoppercent;
		
	pCQueryWnd->m_pctabmodule->Resize();

	ptabmgmt = pCQueryWnd->GetActiveTabEditor()->m_pctabmgmt;

	VERIFY(UpdateWindow(ptabmgmt->m_hwnd));
	//VERIFY(UpdateWindow(ptabmgmt->m_pcdataviewquery->m_hwndgrid));

    return wyTrue;
}
void
ConnectionCommunity::RepaintTabs(WPARAM wparam)
{
	MDIWindow	*wnd = NULL;
	wyInt32		imageid = 0;		

	VERIFY(wnd =  GetActiveWin());
	if(!wnd)
		return;

	imageid = wnd->m_pctabmodule->GetActiveTabImage();

	RepaintTabOnSize();		
	
	return;
}
示例#11
0
wyBool
EditorBase::SelectFirstTableToEdit(wyBool isedit)
{	
	MDIWindow		*wnd = GetActiveWin();
    wyString        currenttable;
    ResultView*     presultview;

    if(!wnd || !wnd->GetActiveTabEditor() || 
		!wnd->GetActiveTabEditor()->m_pctabmgmt || 
        !(presultview = wnd->GetActiveTabEditor()->m_pctabmgmt->m_presultview))
    {
        return wyFalse;
    }
    
    presultview->SelectTableComboItem(isedit == wyTrue ? 1 : 0);
	return wyTrue;
}
void
TableMakerAdvProperties::ReInitRelatedCollations(HWND hwnd, wyWChar *charsetname)
{
    MDIWindow	*pcquerywnd = GetActiveWin();
    MYSQL_RES   *myres;
    MYSQL_ROW   myrow;
    wyWChar     *relcollation  = NULL;
    wyString    query, collationstr;
    wyInt32     ret, selcharsetlen  = 0;

    HWND    hwndcombo = GetDlgItem(hwnd, IDC_TABCOLLATION);

    query.SetAs("show collation");
    myres = ExecuteAndGetResult(pcquerywnd, pcquerywnd->m_tunnel, &pcquerywnd->m_mysql, query);
    if(!myres)
    {
        ShowMySQLError(hwnd, pcquerywnd->m_tunnel, &pcquerywnd->m_mysql, query.GetString());
        return;
    }

    VERIFY((hwndcombo, CB_RESETCONTENT, 0, 0));

    if(charsetname)
        selcharsetlen = wcslen(charsetname);

    while(myrow = pcquerywnd->m_tunnel->mysql_fetch_row(myres))
    {
        collationstr.SetAs(myrow[0]);
        ret = SendMessage(hwndcombo, CB_FINDSTRINGEXACT, -1,(LPARAM)collationstr.GetAsWideChar());
        if(ret != CB_ERR)
        {
            //delete the items which are not relevent
            if(wcsstr(collationstr.GetAsWideChar(), charsetname) == NULL)
                SendMessage(hwndcombo, CB_DELETESTRING, ret, 0);
        }
        else if((relcollation = wcsstr(collationstr.GetAsWideChar(), charsetname)) != NULL)
        {
            // Add the relevent items
            if(collationstr.GetCharAt(selcharsetlen) == '_')
                SendMessage(hwndcombo, CB_ADDSTRING, 0, (LPARAM)collationstr.GetAsWideChar());
        }
    }
    pcquerywnd->m_tunnel->mysql_free_result(myres);
    SendMessage(hwndcombo, CB_SETCURSEL, (WPARAM)0, 0);
}
BOOL
Announcements::HandleEvents(HELEMENT he, BEHAVIOR_EVENT_PARAMS& params)
{
    HWND                    hwndform;
    htmlayout::dom::element src;
	CHttp		http;
	wyString	url_server;
	int status;
	const wchar_t *url = NULL;
	src = params.heTarget; 	
	MDIWindow *wnd = GetActiveWin();
    hwndform = src.get_element_hwnd(true);

	url_server.SetAs("http://www.webyog.com/notifications/");
	switch(params.cmd)
    {
        case HYPERLINK_CLICK:
			url = src.get_attribute("href");	
			if(wcsicmp(url, L"closeann") == 0)
			{
				url_server.AddSprintf("canceled?uuid=%s",pGlobals->m_appuuid.GetString());
				CloseWindow(wnd->m_announcements->m_hwndHTML);
				CloseWindow(wnd->m_announcements->m_hwnd);
				DestroyWindow(wnd->m_announcements->m_hwndHTML);
				DestroyWindow(wnd->m_announcements->m_hwnd);
				pGlobals->m_isannouncementopen = wyFalse;
				wnd->m_pcqueryobject->Resize();
			}
			else
			{
				url_server.AddSprintf("clicked?uuid=%s",pGlobals->m_appuuid.GetString());
				::ShellExecuteW(NULL,L"open", url, NULL,NULL,SW_SHOWNORMAL);
			}
			http.SetUrl(url_server.GetAsWideChar());
			http.SetContentType(L"text/xml");
			http.SendData("abc", 3, false, &status, false );
            return TRUE;
	}
		    
	return FALSE; 
}
wyBool
TabEditorSplitter::Resizeall()
{
	MDIWindow *wnd;
	//TabTypes   *tabtype;

	wnd = GetActiveWin();

	if(!wnd || !wnd->m_pctabmodule)
		return wyFalse;
	
    /*
	tabtype = wnd->m_pctabmodule->GetActiveTabType();

	if(!tabtype)
		return wyFalse;

    tabtype->Resize(wyTrue);
    */

    CustomTab_SetPaintTimer(wnd->m_pctabmodule->m_hwnd);
    wnd->Resize();
	return wyTrue;
}
示例#15
0
// Subclass procedure for the edit box.
LRESULT	CALLBACK 
EditorBase::WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) 
{
	EditorBase *ebase = (EditorBase*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
    MDIWindow   *wnd = NULL;
	wyInt32		ret = 0;
		
	static wyChar	keyword[128];
	static wyBool	keyflag;
	static wyInt32  wrdlen = 0;

    VERIFY(wnd = GetActiveWin());
				
    //if message is from find replace dialog - pass it to the right handler
	//forced type cast
	if(message == (wyUInt32)pGlobals->m_pcmainwin->m_findmsg) 
	{		
		if( ebase->m_findreplace->FindReplace(hwnd, lparam) == wyFalse)
		{
            //when we are closing the find dialog, deleting the memory allocated for Find
			delete(ebase->m_findreplace);
			ebase->m_findreplace = NULL;
		}
		return 0;		
	}    
	
	switch(message)	
	{
	    case WM_HELP:
            ShowHelp("SQL%20Window%20SQLyog%20for%20MySQL%20Administration.htm");
		    return wyTrue;

	    case WM_CONTEXTMENU:
            if(wnd->GetActiveTabEditor())
		    {
			    //CustomGrid_ApplyChanges(wnd->GetActiveTabEditor()->m_pctabmgmt->m_insert->m_hwndgrid, wyTrue);
		    }

            if(ebase->OnContextMenu(lparam) == 1)
            {
                return 1;
            }
		    break;

	    case WM_KEYUP:
	        ebase->OnWMKeyUp(hwnd, wparam);
            break;
		
	    case WM_KEYDOWN:
		    {
			    //This needs to work Ctrl+X to be handled in WM_CHAR, if it wont return '0', that wont process as expected

			    if(GetKeyState(VK_CONTROL) & 0x8000)
			    {
				    if(wparam == 'X')
					    return 0;

				    if(wparam == VK_INSERT)
				    {
					    CopyStyledTextToClipBoard(hwnd);
					    return 0;
				    }
			    }
               
			    if(wnd->m_acinterface->HandlerOnWMKeyDown(hwnd, ebase, wparam))
				    return 1;
		    }
		    break;

        case WM_SYSKEYDOWN:
             if(lparam >> 29)
            {
                //check whether it is insert/delete
                if (wparam == 'C' || wparam == 'c')//switch(wparam)
                {
                    ret = ebase->OnWMChar(hwnd, wparam, wnd, ebase);
                }
            }
             break;

        case WM_SETFOCUS:
            if(wnd)
            {
                PostMessage(wnd->m_pctabmodule->m_hwnd, UM_SETSTATUSLINECOL, (WPARAM)hwnd, 1);
            }

            break;

        case WM_KILLFOCUS:
            if(wnd)
            {
                PostMessage(wnd->m_pctabmodule->m_hwnd, UM_SETSTATUSLINECOL, (WPARAM)NULL, 0);
            }

            break;		
		
	    case WM_LBUTTONUP:
		    ebase->OnLButtonUp(wnd,hwnd);
		    break;

	    case UM_FOCUS:
		    ::SendMessage(hwnd, SCI_GRABFOCUS, 0, 0);
		    break;

	    case WM_CHAR:

		    ret = ebase->OnWMChar(hwnd, wparam, wnd, ebase);

		    if(ret == -1)
			    break;

		    return ret;		

        case UM_ADDBACKQUOTEONAC:
            if(lparam & 1)
            {
                SendMessage(hwnd, SCI_INSERTTEXT, wparam, (LPARAM)"`");
            }

            if(lparam & 2)
            {
               SendMessage(hwnd, SCI_REPLACESEL, (WPARAM)0, (LPARAM)"`");
            }

            SendMessage(hwnd, SCI_ENDUNDOACTION, 0, 0);        
	}

	return CallWindowProc(ebase->wpOrigProc, hwnd, message, wparam, lparam);
}
示例#16
0
BOOL 
HandleClickEventOnLink(HWND hwndLayout, HELEMENT helem, const wchar_t *url)
{
	wyInt32 tabicon;	
	MDIWindow *wnd = GetActiveWin();
	if(url)
	{
		tabicon = wnd->m_pctabmodule->GetActiveTabImage();

		if(tabicon == IDI_DATASEARCH)
		{
#ifndef COMMUNITY			
			TabDbSearch *tabsearch;
			tabsearch = dynamic_cast<TabDbSearch*>(wnd->m_pctabmodule->GetActiveTabType());
			
            if(!tabsearch)
            {
				return FALSE;
            }

			tabsearch->OnHyperLink(helem, url);
#endif
			return true;		
		}

		if(!wcsicmp(url, L"optimizer_help "))
        {
			ShowHelp("Schema%20Optimizer%20SQLyog%20MySQL%20GUI.htm");
        }
        else if(!wcsicmp(url, L"redundantindexes_help "))
        {
            ShowHelp("Redundant%20Indexes%20for%20SQLyog%20MySQL%20Client.htm");
        }
		else if(!wcsicmp(url, L"pref_others ")) 
		{
			PreferenceBase	*pref = CreatePreferences();
			
            if(pref)
			{
				if(pGlobals->m_entlicense.CompareI("Professional"))
				{
					pref->Create(4);
				}
				else
				{
					pref->Create(3);
				}

				delete pref;
			}
		}
		else if(!wcsicmp(url, L"http://www.webyog.com/shop/?ref=community.queryprofiler"))
        {
			::ShellExecuteW(hwndLayout,L"open", url, NULL,NULL,SW_SHOWNORMAL);
        }
        else
        {
            HandleClickTableURL(url);
            PostMessage(hwndLayout, UM_FOCUS, 0, 0);
        }
	}

	return true;		
}
示例#17
0
//this function is called whenever the table link is clicked from the DB level
void HandleClickTableURL(const wchar_t *url)
{
    MDIWindow   *wnd = NULL;
    HTREEITEM   hitem = NULL;
    wyWChar     buff[MAX_PATH] = {0};
    TVITEM      tvitem;

    wnd = GetActiveWin();

    if(!wnd || !wnd->m_pcqueryobject)
    {
		return;
    }

    //switch the current selection image
    switch(wnd->m_pcqueryobject->GetSelectionImage())
    {
        case NDATABASE:
            //get the selection
            hitem = TreeView_GetSelection(wnd->m_pcqueryobject->m_hwnd);

            if(hitem)
            {
                //expand and get the first child
                TreeView_Expand(wnd->m_pcqueryobject->m_hwnd, hitem, TVE_EXPAND);
                hitem = TreeView_GetChild(wnd->m_pcqueryobject->m_hwnd, hitem);
            }
            break;

        case NTABLES:
            //get the selection
            hitem = TreeView_GetSelection(wnd->m_pcqueryobject->m_hwnd);
    }

    if(!hitem)
    {
        return;
    }

    //expand the Tables folder
    TreeView_Expand(wnd->m_pcqueryobject->m_hwnd, hitem, TVE_EXPAND);
    
    //traverse through the tables
    for(hitem = TreeView_GetChild(wnd->m_pcqueryobject->m_hwnd, hitem); hitem; 
        hitem = TreeView_GetNextSibling(wnd->m_pcqueryobject->m_hwnd, hitem))
    {
        //get the item
        tvitem.hItem = hitem;
        tvitem.mask = TVIF_TEXT;
        buff[0] = 0;
        tvitem.pszText = buff;
        tvitem.cchTextMax = MAX_PATH - 1;
        TreeView_GetItem(wnd->m_pcqueryobject->m_hwnd, &tvitem);

        //compare the item with the url
        if(!wcscmp(url, tvitem.pszText))
        {
            //set the selection; this will generate  TVN_SELCHANGING and TVN_SELCHANGED messages
            TreeView_SelectItem(wnd->m_pcqueryobject->m_hwnd, hitem);
            break;
        }
    }

    if(!hitem)
    {
        MDIWindow *wnd = GetActiveWin();
        yog_message(wnd->m_hwnd, PROMPT_MESSAGE, pGlobals->m_appname.GetAsWideChar(), MB_OK | MB_ICONINFORMATION);
    }

    return;
}
示例#18
0
wyInt32  
DBListBuilder::GetDBFromActiveWins(HWND hwnd, LPARAM lparam)
{
	HWND            hwndcombo,hwndtree;
	wyInt32         ret;
	MDIWindow		*pcquerywnd=NULL, *wnd=NULL;
	wyWChar         classname[SIZE_512] = {0};
	wyWChar			database[SIZE_512]  = {0};
    wyString        findvalue, dbname;
	TVITEM			tvi;
	HTREEITEM		hitem;
	LPDIFFCOMBOITEM	pdiffcombo = NULL;

	hwndcombo =(HWND)lparam;

	VERIFY(GetClassName(hwnd, classname, SIZE_512 - 1));

	VERIFY(wnd = GetActiveWin());

	if((wcscmp(classname, QUERY_WINDOW_CLASS_NAME_STR)== 0))
    {
		VERIFY(pcquerywnd = (MDIWindow*)GetWindowLongPtr(hwnd, GWLP_USERDATA));

		hwndtree = pcquerywnd->m_pcqueryobject->m_hwnd;

		hitem = TreeView_GetChild(hwndtree, TreeView_GetRoot(hwndtree));

		while(hitem)	
        {
			memset(&tvi, 0, sizeof(tvi));

			tvi.mask		= TVIF_TEXT;
			tvi.pszText		= database;
			tvi.cchTextMax	= SIZE_512 - 1;
			tvi.hItem		= hitem;

			VERIFY(TreeView_GetItem(hwndtree, &tvi));
			
			dbname.SetAs(database);
			/* starting from 4.1 BETA 4 we use connection name for unique values */
			findvalue.Sprintf("%s - %s", pcquerywnd->m_title.GetString(), dbname.GetString());

			// find it. if not found add it.
			ret = SendMessage(hwndcombo, CB_FINDSTRINGEXACT, -1,(LPARAM)findvalue.GetAsWideChar());

			if(ret == CB_ERR)
            {
				ret = SendMessage(hwndcombo, CB_ADDSTRING, 0,(LPARAM)findvalue.GetAsWideChar());

				pdiffcombo = new DIFFCOMBOITEM;
				
				//wcscpy(pdiffcombo->szDB, database);
				wcsncpy(pdiffcombo->szDB, database, SIZE_128 - 1);
				pdiffcombo->szDB[SIZE_128 - 1] = '\0';
                
				pdiffcombo->wnd = pcquerywnd;
				
				pdiffcombo->mysql = &pcquerywnd->m_mysql;
				pdiffcombo->tunnel = pcquerywnd->m_tunnel;
				pdiffcombo->info = &pcquerywnd->m_conninfo;

				SendMessage(hwndcombo, CB_SETITEMDATA, ret, (LPARAM)pdiffcombo);
			}

			hitem = TreeView_GetNextSibling(hwndtree, hitem);
		}
	}

	return wyTrue;
}
示例#19
0
//Getting databases from MySQL by executing show databases query
wyInt32  
DBListBuilder::GetDBFromServers(HWND hwnd, LPARAM lparam)
{
	HWND            hwndcombo;
	wyInt32         ret;
	MDIWindow		*pcquerywnd=NULL, *wnd=NULL;
	wyWChar         classname[SIZE_512] = {0};
	wyString        dbname, findvalue;
	LPDIFFCOMBOITEM	pdiffcombo = NULL;

	MYSQL_RES			*myres=NULL;
	MYSQL_ROW			myrow;
	wyString            query, database;

    hwndcombo =(HWND)lparam;
	
	VERIFY(GetClassName(hwnd, classname, SIZE_512 - 1));

	VERIFY(wnd = GetActiveWin());

	SetCursor(LoadCursor(NULL, IDC_WAIT));

	if((wcscmp(classname, QUERY_WINDOW_CLASS_NAME_STR)== 0))
    {
		VERIFY(pcquerywnd = (MDIWindow*)GetWindowLongPtr(hwnd, GWLP_USERDATA));
			
		// execute query to get all the database names.
		query.Sprintf("show databases");
        myres = ExecuteAndGetResult(pcquerywnd, pcquerywnd->m_tunnel, &pcquerywnd->m_mysql, query);

		if(!myres)
		{
			ShowMySQLError(hwnd, pcquerywnd->m_tunnel, &pcquerywnd->m_mysql, query.GetString());
			goto cleanup;
		}
		
		while(myrow = pcquerywnd->m_tunnel->mysql_fetch_row(myres))	
		{
			database.SetAs(myrow[0]);
			dbname.SetAs(database);
			/* starting from 4.1 BETA 4 we use connection name for unique values */
			findvalue.Sprintf("%s - %s", pcquerywnd->m_title.GetString(), dbname.GetString());

			// find it. if not found add it.
			ret = SendMessage(hwndcombo, CB_FINDSTRINGEXACT, -1,(LPARAM)findvalue.GetAsWideChar());

			if(ret == CB_ERR)
            {
				ret = SendMessage(hwndcombo, CB_ADDSTRING, 0,(LPARAM)findvalue.GetAsWideChar());

				pdiffcombo = new DIFFCOMBOITEM;
				
				//wcscpy(pdiffcombo->szDB, database.GetAsWideChar());
				wcsncpy(pdiffcombo->szDB, database.GetAsWideChar(), SIZE_128 - 1);
				pdiffcombo->szDB[SIZE_128 - 1] = '\0';
                
				pdiffcombo->wnd = pcquerywnd;
				
				pdiffcombo->mysql = &pcquerywnd->m_mysql;
				pdiffcombo->tunnel = pcquerywnd->m_tunnel;
				pdiffcombo->info = &pcquerywnd->m_conninfo;

				SendMessage(hwndcombo, CB_SETITEMDATA, ret, (LPARAM)pdiffcombo);
			}
		}

		pcquerywnd->m_tunnel->mysql_free_result(myres);
	}

	SetCursor(LoadCursor(NULL, IDC_ARROW));
	return wyTrue;

cleanup:
		SetCursor(LoadCursor(NULL, IDC_ARROW));
		return wyFalse;	
}
示例#20
0
BOOL
HandleClickButton(const wchar_t* buttontext, BEHAVIOR_EVENT_PARAMS& params)
{
    MDIWindow*              wnd = GetActiveWin();
	wyInt32		            tabicon = 0;
    htmlayout::dom::element src = params.heTarget; 	
    htmlayout::dom::element temp;
#ifndef COMMUNITY
    TabObject*              ptabinfo = NULL;
    SchemaOptimizer*        sopt = NULL;
    RedundantIndexFinder*   redindfinder = NULL;
	TabDbSearch*            tabsearch;    
    TabEditor*              ptabeditor = wnd->m_pctabmodule->GetActiveTabEditor();
#endif

    tabicon = wnd->m_pctabmodule->GetActiveTabImage();

    if(!wnd || !wnd->m_pctabmodule || !buttontext || !wcslen(buttontext))
    {
		return FALSE;
    }

#ifndef COMMUNITY	
	if(tabicon == IDI_DATASEARCH)
	{
		if(!(tabsearch = (TabDbSearch*)wnd->m_pctabmodule->GetActiveTabType()))
        {
            return FALSE;
        }
		
        tabsearch->OnSearchButton();
        return FALSE;
	}
	else if(tabicon == IDI_TABLEINDEX)
	{
		ptabinfo = (TabObject*)wnd->m_pctabmodule->GetActiveTabType();
		
        if(!ptabinfo || !ptabinfo->m_pobjinfo->m_schemaoptimize || !ptabinfo->m_pobjinfo->m_redindexfinder)
        {
			return FALSE;
        }

        sopt = ptabinfo->m_pobjinfo->m_schemaoptimize;
        redindfinder = ptabinfo->m_pobjinfo->m_redindexfinder;
	}
    else if(ptabeditor && ptabeditor->m_pctabmgmt->GetActiveTabIcon() == IDI_TABLEINDEX)
    {
        sopt = ptabeditor->m_pctabmgmt->m_pqueryobj->m_pobjectinfo->m_schemaoptimize;
        redindfinder = ptabeditor->m_pctabmgmt->m_pqueryobj->m_pobjectinfo->m_redindexfinder;
    }
    else
    {
        return FALSE;
    }
    
    if(!sopt->m_tabinfo || !redindfinder->m_tabinfo)
	{
		return FALSE;
	}
#endif

    if(wcsicmp(buttontext, OPTIMIZER_CALCULATE) == 0 || 
       wcsicmp(buttontext, REDUNDANT_INDEX_FIND) == 0)
	{
#ifndef COMMUNITY
        if(pGlobals->m_pcmainwin->m_connection->m_enttype != ENT_PRO && 
           pGlobals->m_pcmainwin->m_connection->m_enttype != ENT_NORMAL)
        {
            if(wcsicmp(buttontext, OPTIMIZER_CALCULATE) == 0)
            {
	    	    sopt->ProcessTableAnalyse();		
            }
            else
            {
                if(redindfinder->ProcessFind() == wyTrue)
                {
                    //scroll the element into view
                    temp = htmlayout::dom::element::root_element(ptabinfo->m_pobjinfo->m_hwndhtmleditor);
                    temp = temp.get_element_by_id(L"indexinfo");
                    temp.scroll_to_view(true, false);
                }                
            }
        }
#else		
		pGlobals->m_pcmainwin->m_connection->GetSQLyogUltimateDialog();
		return TRUE;
#endif
	}
#ifndef COMMUNITY		
	else if(wcsicmp(buttontext, OPTIMIZER_STOP) == 0)
	{		
		sopt->StopExecution(wnd);

		//Resetting the Button text
		if(sopt->m_ismysqlerror == wyTrue)
		{
			src.set_text(_(L"Calculate Optimal Datatypes"));
		}
	}
	else if(wcsicmp(buttontext, OPTIMIZER_HIDE) == 0)
	{		
        if(ptabinfo && ptabinfo->m_pobjinfo)
        {
		    ptabinfo->m_pobjinfo->m_istableanalyse = wyFalse;
		    ptabinfo->m_pobjinfo->m_istohideoptimizecolumn = wyTrue;
		    ptabinfo->OnSelectInfoTab(sopt->m_con);
		    ptabinfo->m_pobjinfo->m_istohideoptimizecolumn = wyFalse;
        }
        else if(ptabeditor && ptabeditor->m_pctabmgmt->m_pqueryobj)
        {
            ptabeditor->m_pctabmgmt->m_pqueryobj->m_pobjectinfo->m_istableanalyse = wyFalse;
		    ptabeditor->m_pctabmgmt->m_pqueryobj->m_pobjectinfo->m_istohideoptimizecolumn = wyTrue;
            ptabeditor->m_pctabmgmt->m_pqueryobj->Refresh(wyTrue);
		    ptabeditor->m_pctabmgmt->m_pqueryobj->m_pobjectinfo->m_istohideoptimizecolumn = wyFalse;
        }
	}
    else if(wcsicmp(buttontext, REDUNDANT_INDEX_HIDE)== 0)
    {
        //hide the redundant indexes info
        redindfinder->HideColumns();
        //scroll the element into view
        temp = htmlayout::dom::element::root_element(ptabinfo->m_pobjinfo->m_hwndhtmleditor);
        temp = temp.get_element_by_id(L"indexinfo");
        temp.scroll_to_view(true, false);
    }
#endif
    return FALSE;
}
wyBool
ExportAsSimpleSQL::WriteInsertStatement(ExportSQLData *data)
{
	wyInt32		    messagecount = 0, rowcount = 0, rowptr = 0;
	wyString	    value, messbuff, table;
    wyBool          ismysql41 = IsMySQL41(m_tunnel, m_mysql), retval = wyTrue;
	MYSQL_ROWS		*rowswalker = NULL;
	//HWND			hwndgrid;
	MDIWindow		*wnd;

	wnd = GetActiveWin();

	/*if(wnd &&
		wnd->GetActiveTabEditor() &&
		wnd->GetActiveTabEditor()->m_pctabmgmt &&
		wnd->GetActiveTabEditor()->m_pctabmgmt->m_pcdataviewquery &&
		wnd->GetActiveTabEditor()->m_pctabmgmt->m_pcdataviewquery->m_hwndgrid)
	{
		hwndgrid = wnd->GetActiveTabEditor()->m_pctabmgmt->m_pcdataviewquery->m_hwndgrid;
	}*/
	   
	m_tunnel->mysql_data_seek(m_myres,(my_ulonglong)0);

/*	if(data->m_tabrec->m_data)
		tmp = data->m_tabrec->m_data->m_data; */	

	while(1)
    {        	
		if(*data->m_stopped == wyTrue)
        {
            SetWindowText(GetDlgItem(data->m_hwnd, IDC_MESSAGE), _(L"Aborted by user"));
			return wyFalse;
        }
		
		//If exporting from result tab with edit mode 'data->m_tabrec->m_data' will not be NULL , this contains rows to export.
		//If export from 'Tabletab' or result tab in 'read only mode' use the normal MYSQL_RES pointer, to retrive the data
        if(!data->m_tabrec->m_rowarray->GetLength())
		{	
			if(m_isdatafromquery == wyTrue)
			{
				//If use mysql_useresult() then we should use this
				m_myrow = m_tunnel->mysql_fetch_row(m_myres);
			}

			else
			{
				SeekCurrentRowFromMySQLResult(m_myres, &rowswalker, m_tunnel, &m_myrow, &m_rowlength);
			}

			if(!m_myrow)
			{
				//SendMessage(hwndgrid, WM_SETREDRAW, TRUE, 0);
				break;
			}		
		}

		//In result tab with 'edit' mode or the result is edited
		else 
        {
            //bug fixed.http://code.google.com/p/sqlyog/issues/detail?id=494
			//no need to export unsaved row.. if it is a saved row then m_newrow =wyFalse
            if(rowptr == data->m_tabrec->m_rowarray->GetLength())
                break;

            //no need to export unsaved row.. if it is a saved row then m_newrow =wyFalse
            
            
            if(data->m_tabrec->m_rowarray->GetRowExAt(rowptr)->IsNewRow())
			{
                rowptr++;
                break;
            }
            if(data->m_tabrec->m_modifiedrow >=0 && data->m_tabrec->m_modifiedrow == rowcount && data->m_tabrec->m_oldrow->IsNewRow() == wyFalse)
            {
                m_myrow = data->m_tabrec->m_oldrow->m_row;
            }
            else
            {
                m_myrow = data->m_tabrec->m_rowarray->GetRowExAt(rowptr)->m_row;
            }

            rowptr++;
        }

        if(ismysql41 == wyTrue)
            value.Sprintf("insert into `%s` ", data->m_tablename.GetString());
        else
        {
            //table.SetAs(data->m_tabrec->m_table.GetString());    
            value.Sprintf("insert into `%s` ", data->m_tablename.GetAsAnsi());
        }
		AddColumnNames(data, value);
		value.Add("values(");

		retval = AddValues(data, value);

		/*if(!data->m_tabrec->m_data)
		{
			SendMessage(hwndgrid, WM_SETREDRAW, TRUE, 0);
		}*/

		//Freeing the buffer that keeps the row-lengths
		if(m_rowlength)
		{
			free(m_rowlength);
			m_rowlength = NULL;
		}

		if(retval == wyFalse)
		{
			return wyFalse;
		}

		value.Strip(1); /// Strip 1 for the last ','
		value.Add(");\r\n");

		messbuff.Sprintf(_("  %d Rows Exported"), ++messagecount);
        SendMessage(data->m_hwndmessage, WM_SETTEXT, 0, (LPARAM)messbuff.GetAsWideChar());

		if(WriteToFile(value) == wyFalse)
			return wyFalse;
        rowcount++;
	}

	value.Add(";\r\n");

	if(m_rowlength)
	{
		free(m_rowlength);
		m_rowlength = NULL;
	}
	return wyTrue;
}
wyBool 
ImportBatch::ExecuteBatch()
{
	wyString        msg;
	wyUInt32		timetaken;
	wyUInt32		thdid;
	HANDLE			impthd = NULL;
	ImportFromSQL	import;

	MDIWindow		*wnd = NULL;
    
	IMPORTBATCH		evt = {0};
	IMPORTPARAM		param = {0};

//	DEBUG_ENTER ( "Executebatch" );

	VERIFY(wnd = GetActiveWin());

	/* set the yogimport and importparam values */
	SetImportValues(&import);
	SetParamValues(&param);

	/* set initial progress bar values */
	if(!(param.m_totalfilesize = SetInitProgressValues()))
    {
        ShowEmptyFileError(&param);
        return wyFalse;
	}

	param.m_count = 0;
	
	/* disable the button and other windows */
	EnableDlgWindows(wyFalse);
	EnableWindow(GetDlgItem(m_hwnd, IDDONE ), false);

	SetFocus(GetDlgItem(m_hwnd, IDC_PROGRESS));
	/* change text of the ok button */
	ChangeOKButtonText(_(L"S&top"));

	VERIFY(evt.m_impevent	= CreateEvent(NULL, TRUE, FALSE, NULL));
	evt.m_import		= &import;
	evt.m_lpParam		= &param;
	evt.m_stopquery	= (wyBool*)&m_stopimport;
	evt.wnd = wnd;

//	DEBUG_LOG("%u - created", &evt.m_impevent);

	timetaken = GetTickCount();
	m_importing = wyTrue;
//	DEBUG_LOG("Creating thread");
	impthd = (HANDLE)_beginthreadex(NULL, 0, ImportBatch::ImportThread, &evt, 0, &thdid);

	if(!impthd)
    	goto cleanup;

	/* handle all other GUI messages and all in the main thread */
//	DEBUG_LOG("Handling messages");
	HandleMsgs(evt.m_impevent, wyFalse);
	timetaken = GetTickCount() - timetaken;
	VERIFY(CloseHandle(evt.m_impevent));
	VERIFY(CloseHandle(impthd));
    ImportConclude(&evt, &param);
    return wyTrue;

cleanup:
	if(evt.m_impevent)
		VERIFY(CloseHandle(evt.m_impevent));

	if(impthd)
		VERIFY(CloseHandle(impthd));

	m_importing = m_stopimport = wyFalse;
	EnableDlgWindows(wyTrue);
	ChangeOKButtonText(_(L"&Execute"));
	return wyFalse;
}
示例#23
0
wyInt32
EditorBase::OnContextMenuHelper(LPARAM lParam)
{
	wyBool	    nmenuselect;
	LONG	    lstyle=0;
	HMENU	    hmenu, htrackmenu;
	POINT	    pnt;
	wyInt32		pos;
    RECT        rect;
    MDIWindow*  wnd = GetActiveWin();

	VERIFY(hmenu = GetMenu(pGlobals->m_pcmainwin->m_hwndmain));

	//lStyle = GetWindowLongPtr ( m_hwndparent, GWL_STYLE );
	lstyle = GetWindowLongPtr(GetParent(m_hwndparent), GWL_STYLE);

    if ((lstyle & WS_MAXIMIZE) && wyTheme::IsSysmenuEnabled(GetParent(m_hwndparent)))
		VERIFY(htrackmenu =	GetSubMenu(hmenu, 2));
	else
		VERIFY(htrackmenu =	GetSubMenu(hmenu, 1));

	//If we are pressing the context button,then lParam is -1.
	if(lParam == -1)
	{		
		//for getting the current cursor pos.
		pos = SendMessage(m_hwnd, SCI_GETCURRENTPOS, 0, 0);
		pnt.x = SendMessage(m_hwnd, SCI_POINTXFROMPOSITION, 0, pos) ; 
		pnt.y = SendMessage(m_hwnd, SCI_POINTYFROMPOSITION, 0, pos); 
		VERIFY(ClientToScreen(m_hwnd, &pnt));
	}
	else
	{
		pnt.x = GET_X_LPARAM(lParam); 
		pnt.y = GET_Y_LPARAM(lParam); 
	}

    GetClientRect(m_hwnd, &rect);
    MapWindowPoints(m_hwnd, NULL, (LPPOINT)&rect, 2);

    if(!PtInRect(&rect, pnt))
    {
        return -1;
    }

	//VERIFY(ClientToScreen(m_hwnd, &pnt));
    SetFocus(m_hwnd);

	// Now change the menu item.
	ChangeEditMenuItem(htrackmenu);

    pGlobals->m_pcmainwin->m_connection->HandleTagsMenu((HMENU)hmenu);

    if(wnd)
    {
        //FrameWindow::RecursiveMenuEnable(htrackmenu, wyFalse, MF_ENABLED);

        if(wnd->m_executing == wyTrue || wnd->m_pingexecuting == wyTrue)
        {
            FrameWindow::RecursiveMenuEnable(htrackmenu, wyFalse, MF_DISABLED);
        }

        wyTheme::SetMenuItemOwnerDraw(htrackmenu);
	    nmenuselect = (wyBool)TrackPopupMenu(htrackmenu, TPM_LEFTALIGN | TPM_RIGHTBUTTON, pnt.x, pnt.y, 0, pGlobals->m_pcmainwin->m_hwndmain, NULL);
    }
    return 1;
}