Beispiel #1
0
void CEditWnd::Init(CEditUI* pOwner)
{
    m_pOwner = pOwner;
    RECT rcPos = CalPos();
    UINT uStyle = WS_CHILD | ES_AUTOHSCROLL;

    if (m_pOwner->IsPasswordMode()) uStyle |= ES_PASSWORD;
    
	Create(m_pOwner->GetManager()->GetPaintWindow(), NULL, uStyle, 0, rcPos);
    SetWindowFont(m_hWnd, m_pOwner->GetManager()->GetFontInfo(m_pOwner->GetFont())->hFont, TRUE);
    Edit_LimitText(m_hWnd, m_pOwner->GetMaxChar());
    
	if (m_pOwner->IsPasswordMode()) Edit_SetPasswordChar(m_hWnd, m_pOwner->GetPasswordChar());
    
	Edit_SetText(m_hWnd, m_pOwner->GetText());
    Edit_SetModify(m_hWnd, FALSE);
    
	SendMessage(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELPARAM(0, 0));
    Edit_Enable(m_hWnd, m_pOwner->IsEnabled() == true);
    Edit_SetReadOnly(m_hWnd, m_pOwner->IsReadOnly() == true);
    
	::ShowWindow(m_hWnd, SW_SHOWNOACTIVATE);
    ::SetFocus(m_hWnd);
    m_bInit = true;
}
Beispiel #2
0
void CPathEditWnd::Init( CPathEditUI* pOwner )
{
	m_pOwner = pOwner;
	RECT rcPos = CalPos();
	UINT uStyle = WS_CHILD | ES_AUTOHSCROLL;
	if( m_pOwner->IsPasswordMode() ) uStyle |= ES_PASSWORD;
	Create(m_pOwner->GetManager()->GetPaintWindow(), NULL, uStyle, 0, rcPos);
	HFONT hFont=NULL;
	int iFontIndex=m_pOwner->GetFont();
	if (iFontIndex!=-1)
		hFont=m_pOwner->GetManager()->GetFont(iFontIndex);
	if (hFont==NULL)
		hFont=m_pOwner->GetManager()->GetDefaultFontInfo()->hFont;

	SetWindowFont(m_hWnd, hFont, TRUE);
	Edit_LimitText(m_hWnd, m_pOwner->GetMaxChar());
	if( m_pOwner->IsPasswordMode() ) Edit_SetPasswordChar(m_hWnd, m_pOwner->GetPasswordChar());
	Edit_SetText(m_hWnd, m_pOwner->GetText());
	Edit_SetModify(m_hWnd, FALSE);
	SendMessage(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELPARAM(0, 0));
	Edit_Enable(m_hWnd, m_pOwner->IsEnabled() == true);
	Edit_SetReadOnly(m_hWnd, m_pOwner->IsReadOnly() == true);
	//Styls
	LONG styleValue = ::GetWindowLong(m_hWnd, GWL_STYLE);
	styleValue |= pOwner->GetWindowStyls();
	::SetWindowLong(GetHWND(), GWL_STYLE, styleValue);
	::ShowWindow(m_hWnd, SW_SHOWNOACTIVATE);
	::SetFocus(m_hWnd);
	m_bInit = true;    
}
Beispiel #3
0
void UpdateOptionsDialogText(HWND dlg)
{
	HWND searchEdit = GetDlgItem(dlg, IDC_EDIT_SEARCHENGINEFORMAT);
	SetDlgItemText(dlg, IDC_EDIT_SEARCHENGINEFORMAT, SearchEngine::GetCurrent().FormatString().c_str());
	SetDlgItemText(dlg, IDC_STATIC_BROWSERPATH, Browser::GetCurrent().ExecutableFilename().c_str());
	SetDlgItemText(dlg, IDC_EDIT_BROWSERPARAMETERS, Browser::GetCurrent().CommandLine().c_str());
	Edit_SetReadOnly(searchEdit, !SearchEngine::GetCurrent().IsCustom());
}
Beispiel #4
0
	void CEditUI::SetReadOnly(bool bReadOnly)
	{
		if( m_bReadOnly == bReadOnly ) return;

		m_bReadOnly = bReadOnly;
		if( m_pWindow != NULL ) Edit_SetReadOnly(*m_pWindow, m_bReadOnly);
		Invalidate();
	}
Beispiel #5
0
void CMultiLineEditWnd::Init(CMultiLineEditUI* pOwner)
{
   RECT rcPos = pOwner->GetPos();
   ::InflateRect(&rcPos, -1, -3);
   Create(pOwner->m_pManager->GetPaintWindow(), NULL, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL, 0, rcPos);
   SetWindowFont(m_hWnd, pOwner->m_pManager->GetThemeFont(UIFONT_NORMAL), TRUE);
   Edit_SetText(m_hWnd, pOwner->m_sText);
   Edit_SetModify(m_hWnd, FALSE);
   SendMessage(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELPARAM(2, 2));
   Edit_SetReadOnly(m_hWnd, pOwner->IsReadOnly() == true);
   Edit_Enable(m_hWnd, pOwner->IsEnabled() == true);
   if( pOwner->IsVisible() ) ::ShowWindow(m_hWnd, SW_SHOWNOACTIVATE);
   m_pOwner = pOwner;
}
BOOL TabPage_6_OnInitDialog(HWND hDlg,WPARAM wParam,LPARAM lParm)
{
	TabPage_6_FillComboBox(GetDlgItem(hDlg,ComboBoxID),Graph_Type);

	// 限定输入字符个数
	Edit_LimitText(GetDlgItem(hDlg,EditControlID[1]),255);
	Edit_LimitText(GetDlgItem(hDlg,EditControlID[2]),5);
	Edit_LimitText(GetDlgItem(hDlg,EditControlID[3]),5);

	Button_SetCheck(GetDlgItem(hDlg,CheckBoxID),BST_CHECKED);
	Edit_SetReadOnly(GetDlgItem(hDlg,EditControlID[1]),TRUE);

	Edit_SetText(GetDlgItem(hDlg,EditControlID[0]),TEXT("数据输入"));
	return TRUE;
}
Beispiel #7
0
void CSingleLineEditWnd::Init(CSingleLineEditUI* pOwner)
{
   CRect rcPos = pOwner->GetPos();
   rcPos.Deflate(1, 3);
   Create(pOwner->GetManager()->GetPaintWindow(), NULL, WS_CHILD | pOwner->m_uEditStyle, 0, rcPos);
   SetWindowFont(m_hWnd, pOwner->GetManager()->GetThemeFont(UIFONT_NORMAL), TRUE);
   Edit_SetText(m_hWnd, pOwner->GetText());
   Edit_SetModify(m_hWnd, FALSE);
   SendMessage(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELPARAM(2, 2));
   Edit_SetSel(m_hWnd, 0, -1);
   Edit_Enable(m_hWnd, pOwner->IsEnabled() == true);
   Edit_SetReadOnly(m_hWnd, pOwner->IsReadOnly() == true);
   ::ShowWindow(m_hWnd, SW_SHOWNOACTIVATE);
   ::SetFocus(m_hWnd);
   m_pOwner = pOwner;
}
void CMultiLineEditWnd::Init(CMultiLineEditUI* pOwner)
{
    CRect rcPos = pOwner->GetPos();
#if 1
    Create(pOwner->m_pCanvas->GetHWND(), NULL, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | ES_MULTILINE | WS_VSCROLL | ES_AUTOVSCROLL, 0, rcPos);
#else
    Create(pOwner->m_pManager->GetPaintWindow(), NULL, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | ES_MULTILINE | WS_VSCROLL | ES_AUTOVSCROLL, 0, rcPos);
#endif
    SetWindowFont(m_hWnd, pOwner->GetManager()->GetDefaultFont(), TRUE);
    Edit_SetText(m_hWnd, pOwner->m_sText);
    Edit_SetModify(m_hWnd, FALSE);
    SendMessage(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELPARAM(2, 2));
    Edit_SetReadOnly(m_hWnd, pOwner->IsReadOnly() == true);
    Edit_Enable(m_hWnd, pOwner->IsEnabled() == true);
    if( pOwner->IsVisible() ) ::ShowWindow(m_hWnd, SW_SHOWNOACTIVATE);
    m_pOwner = pOwner;
}
my_bool DSNDialog(HWND hwndParent,
                  WORD fRequest,
                  LPCSTR lpszDriver,
                  LPCSTR lpszAttributes,
                  MADB_Dsn *Dsn)
{
  MSG msg;
  BOOL ret;
  char *DsnName= NULL;
  my_bool DsnExists= FALSE;

  if (Dsn->isPrompt < 0 || Dsn->isPrompt > MAODBC_PROMPT_REQUIRED)
  {
    Dsn->isPrompt= MAODBC_CONFIG;
  }

  EffectiveDisabledPages=     DisabledPages[Dsn->isPrompt];
  EffectiveDisabledControls=  DisabledControls[Dsn->isPrompt];

  if (lpszAttributes)
    DsnName= strchr((char *)lpszAttributes, '=');
  
  if (lpszDriver)
    MADB_DriverGet((char *)lpszDriver);

  if (DsnName)
  {
    ++DsnName;
    /* In case of prompting we are supposed to show dialog even DSN name is incorrect */
    if (!Dsn->isPrompt && !SQLValidDSN(DsnName))
    {
      if (hwndParent)
        MessageBox(hwndParent, "Validation of data source name failed", "Error", MB_ICONERROR | MB_OK);
      return FALSE;
    }
  }

  if (!DsnName && Dsn && Dsn->DSNName)
  {
    DsnName= Dsn->DSNName;
  }
  else if (DsnName && Dsn)
  {
    /* Need to free current value in Dsn->DSNName */
    MADB_SUBSTITUTE(Dsn->DSNName, _strdup(DsnName));
  }

  /* Even if DsnName invalid(in case of prompt) - we should not have problem */
  DsnExists= MADB_DSN_Exists(DsnName);
 
  InitCommonControls();

  if (lpszDriver)
    Dsn->Driver= _strdup(lpszDriver);

  SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &Environment);
  SQLSetEnvAttr(Environment, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)SQL_OV_ODBC3, 0);

  if (fRequest == ODBC_ADD_DSN)
  {
    if (DsnExists && hwndParent)
    {
      if (MessageBox(hwndParent, "Data source name already exists, do you want to replace it?", 
                      "Question", MB_ICONQUESTION | MB_YESNO) != IDYES)
        return FALSE;
    }
    Dsn->IsTcpIp= 1;
  }
  else
  {
    /* i.e. not a prompt */
    if (Dsn->isPrompt == MAODBC_CONFIG)
    {
      if (!DsnExists)
      {
        MessageBox(0, "Data source name not found", "Error", MB_ICONERROR | MB_OK);
        return FALSE;
      }
      else if (!MADB_ReadDSN(Dsn, (char *)lpszAttributes, TRUE))
      {
        SQLPostInstallerError(ODBC_ERROR_INVALID_DSN, Dsn->ErrorMsg);
        return FALSE;
      }
    }
  }

  notCanceled= TRUE;
  hwndMain= CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), 0, DialogProc, 0);
  SetWindowLongPtr(hwndMain, DWLP_USER, (LONG)Dsn);

  /* Setting first not disabled page */
  CurrentPage= -1;
  SetPage(hwndMain, 1);

  Edit_SetReadOnly(GetDlgItem(hwndTab[0], txtDsnName), 
                   (hwndParent && DsnName && fRequest == ODBC_ADD_DSN) ? TRUE : FALSE);

  SetDialogFields();
  CenterWindow(hwndMain);
  ShowWindow(hwndMain, SW_SHOW);

  while((ret = GetMessage(&msg, 0, 0, 0)) != 0) {
    if(ret == -1)
      break;

    if(!IsDialogMessage(hwndTab[CurrentPage], &msg)) {
      TranslateMessage(&msg);
      DispatchMessage(&msg);
    }
  }

  SQLFreeHandle(SQL_HANDLE_ENV, Environment);

  return notCanceled;
}
Beispiel #10
0
/*
* DescDialogProc:  Dialog procedure for dialog containing an
*   item's long description.
*/
BOOL CALLBACK DescDialogProc(HWND hDlg, UINT message, UINT wParam, LONG lParam)
{
	DescDialogStruct *info;
	static HWND hwndBitmap;
	static Bool changed;   // True when player has changed description
	HWND hEdit, hwndOK, hURL, hFixed;
	HDC hdc;
	HFONT hFont;
	RECT dlg_rect, edit_rect, fixed_rect;
	AREA area;
	char *desc, *str, url[MAX_URL + 1], *pPageBreak;
	DRAWITEMSTRUCT *lpdis;
	char descriptionBuffer[MAX_PAGE_DESCRIPTION_TEXT+1];
	int height;
	
	info = (DescDialogStruct *) GetWindowLong(hDlg, DWL_USER);
	
	switch (message)
	{
	case WM_INITDIALOG:
		info = (DescDialogStruct *) lParam;
		/* Store structure in dialog box's extra bytes */
		SetWindowLong(hDlg, DWL_USER, (long) info);
		
		hwndBitmap = GetDlgItem(hDlg, IDC_DESCBITMAP);
		hFixed = GetDlgItem(hDlg, IDC_DESCFIXED);
		hEdit = GetDlgItem(hDlg, IDC_DESCBOX);
		hwndOK = GetDlgItem(hDlg, IDOK);
		
		// Item Name.
		height = SetFontToFitText(info,GetDlgItem(hDlg, IDC_DESCNAME), 
			(int)FONT_TITLES, info->name);
		SetDlgItemText(hDlg, IDC_DESCNAME, info->name);
		hdc = GetDC(hDlg);
		SetTextColor(hdc,GetPlayerNameColor(info->obj,info->name));
		ReleaseDC(hDlg,hdc);
		
		// Item Description.
		hFont = GetFont(FONT_EDIT);
		SetWindowFont(hFixed, hFont, FALSE);
		SetWindowFont(hEdit, hFont, FALSE);
		
		str = info->description;
		if (str)
		{
			pPageBreak = strchr(str,PAGE_BREAK_CHAR);
			while (pPageBreak)
			{
				info->numPages++;
				str = pPageBreak+1;
				pPageBreak = strchr(str,PAGE_BREAK_CHAR);
			}
			info->numPages++;
			GetPageText(descriptionBuffer,info);
			Edit_SetText(hEdit, descriptionBuffer);
		}
		
		// Show fixed string, if appropriate
		if (info->fixed_string != NULL)
		{
			SetDlgItemText(hDlg, IDC_DESCFIXED, info->fixed_string);
			SetWindowFont(GetDlgItem(hDlg, IDC_DESCFIXED), GetFont(FONT_EDIT), FALSE);
		}
		
		// Can this player edit this object's description?
		if (info->flags & DF_EDITABLE)
			Edit_SetReadOnly(hEdit, FALSE);
		Edit_LimitText(hEdit, MAX_DESCRIPTION);
		if (!(info->flags & (DF_EDITABLE | DF_INSCRIBED)) && !str)
		{
			GetWindowRect(hFixed, &fixed_rect);
			GetWindowRect(hEdit, &edit_rect);
			UnionRect(&fixed_rect, &fixed_rect, &edit_rect);
			ScreenToClient(hDlg, (LPPOINT)(&fixed_rect));
			ScreenToClient(hDlg, (LPPOINT)(&fixed_rect)+1);
			MoveWindow(hFixed, fixed_rect.left, fixed_rect.top,
				fixed_rect.right - fixed_rect.left,
				fixed_rect.bottom - fixed_rect.top, FALSE);
			ShowWindow(hEdit, SW_HIDE);
		}
		
		// Resize and move dialog controls
		GetWindowRect(hDlg, &dlg_rect);
		if (GetWindowLong(hEdit, GWL_STYLE) & WS_VISIBLE)
		{
			ShowWindow(hEdit, SW_HIDE);
			ResizeEditToFitText(hFixed, hFont);
			ResizeDialog(hDlg, &dlg_rect, desc_controls);
			ShowWindow(hEdit, SW_SHOW);
		}
		else
		{
			ResizeEditToFitText(hFixed, hFont);
			ResizeDialog(hDlg, &dlg_rect, desc_controls);
		}
		if (GetWindowLong(hEdit, GWL_STYLE) & WS_VISIBLE)
		{
			GetWindowRect(hFixed, &fixed_rect);
			GetWindowRect(hEdit, &edit_rect);
			height = fixed_rect.bottom-edit_rect.top;
			ScreenToClient(hDlg, (LPPOINT)(&edit_rect));
			ScreenToClient(hDlg, (LPPOINT)(&edit_rect)+1);
			ShowWindow(hFixed, SW_HIDE);
			OffsetRect(&edit_rect, 0, height);
			MoveWindow(hEdit, edit_rect.left, edit_rect.top,
				edit_rect.right - edit_rect.left,
				edit_rect.bottom - edit_rect.top, FALSE);
			GetWindowRect(hDlg, &dlg_rect);
			ResizeEditToFitText(hEdit, hFont);
			ResizeDialog(hDlg, &dlg_rect, desc_controls);
			ShowWindow(hFixed, SW_SHOW);
		}
		
		CenterWindow(hDlg, GetParent(hDlg));
		
		// Show URL, if appropriate
		if (info->url != NULL)
		{
			hURL = GetDlgItem(hDlg, IDC_URL);
			
			SetWindowText(hURL, info->url);
			SetWindowFont(hURL, GetFont(FONT_EDIT), FALSE);
			
			if (info->flags & DF_EDITABLE)
				Edit_SetReadOnly(hURL, FALSE);
			
			Edit_LimitText(hURL, MAX_URL);
		}
		
		// Show appropriate buttons
		if (!(desc_flags & DESC_GET))
			DestroyWindow(GetDlgItem(hDlg, IDC_GET));
		if (!(desc_flags & DESC_DROP))
			DestroyWindow(GetDlgItem(hDlg, IDC_DROP));
		if (!(desc_flags & DESC_USE))
			DestroyWindow(GetDlgItem(hDlg, IDC_USE));
		if (!(desc_flags & DESC_UNUSE))
			DestroyWindow(GetDlgItem(hDlg, IDC_UNUSE));
		if (!(desc_flags & DESC_INSIDE))
			DestroyWindow(GetDlgItem(hDlg, IDC_INSIDE));
		if (!(desc_flags & DESC_ACTIVATE))
			DestroyWindow(GetDlgItem(hDlg, IDC_ACTIVATE));
		if (!(desc_flags & DESC_APPLY))
			DestroyWindow(GetDlgItem(hDlg, IDC_APPLY));
		
		SetLookPageButtons(hDlg, info);
#if 0
		if (info->numPages < 2)
		{
			HWND hwnd = GetDlgItem(hDlg,IDC_NEXT);
			if (hwnd)
				DestroyWindow(GetDlgItem(hDlg, IDC_NEXT));
			hwnd = GetDlgItem(hDlg,IDC_PREV);
			if (hwnd)
				DestroyWindow(GetDlgItem(hDlg, IDC_PREV));
		}
		else 
		{
			HWND hwnd = GetDlgItem(hDlg,IDC_PREV);
			if (hwnd)
				EnableWindow(hwnd,FALSE);
		}
#endif
		SetFocus(hwndOK);
		hDescDialog = hDlg;
		changed = False;
		return FALSE;
		
   case WM_PAINT:
	   InvalidateRect(hwndBitmap, NULL, TRUE);
	   UpdateWindow(hwndBitmap);
	   /* fall through */
	   
   case BK_ANIMATE:
	   /* Draw object's bitmap */
	   hdc = GetDC(hwndBitmap);
	   GetClientRect(hwndBitmap, &dlg_rect);
	   
	   RectToArea(&dlg_rect, &area);
	   DrawStretchedObjectGroup(hdc, info->obj, info->obj->animate->group, &area, 
		   GetSysColorBrush(COLOR_3DFACE));
	   
	   ReleaseDC(hwndBitmap, hdc);
	   break;
	   
	   HANDLE_MSG(hDlg, WM_CTLCOLOREDIT, DialogCtlColor);
	   HANDLE_MSG(hDlg, WM_CTLCOLORLISTBOX, DialogCtlColor);
	   HANDLE_MSG(hDlg, WM_CTLCOLORSTATIC, DialogCtlColor);
	   HANDLE_MSG(hDlg, WM_CTLCOLORDLG, DialogCtlColor);
	   
   case WM_DESTROY:
	   hDescDialog = NULL;
	   return TRUE;   
	   
   case WM_DRAWITEM:
	   // Draw player name in color that reflects murderer status
	   lpdis = (DRAWITEMSTRUCT *) lParam;
	   switch (lpdis->itemAction)
       {
       case ODA_SELECT:
       case ODA_DRAWENTIRE:
		   SelectPalette(lpdis->hDC, hPal, FALSE);
		   hFont = info->hFontTitle;
		   SelectObject(lpdis->hDC, hFont);
		   SetBkMode(lpdis->hDC, TRANSPARENT);
		   str = LookupNameRsc(info->obj->name_res);
		   SetTextColor(lpdis->hDC, NAME_COLOR_NORMAL_BG);
		   DrawText(lpdis->hDC, str, strlen(str), &lpdis->rcItem, DT_LEFT | DT_VCENTER | DT_NOPREFIX);
		   OffsetRect(&lpdis->rcItem, -1, -1);
		   SetTextColor(lpdis->hDC, GetPlayerNameColor(info->obj, info->name));
		   DrawText(lpdis->hDC, str, strlen(str), &lpdis->rcItem, DT_LEFT | DT_VCENTER | DT_NOPREFIX);
		   
		   break;
       }
	   return TRUE;
	   
	   case WM_COMMAND:
		   switch(GET_WM_COMMAND_ID(wParam, lParam))
		   {
		   case IDC_PREV:
			   if (info->currentPage > 0)
				   info->currentPage--;
			   GetPageText(descriptionBuffer,info);
			   SetLookPageButtons(hDlg, info);
			   Edit_SetText(GetDlgItem(hDlg, IDC_DESCBOX), descriptionBuffer);
#if 0
			   EnableWindow(GetDlgItem(hDlg,IDC_PREV),info->currentPage > 0);
			   EnableWindow(GetDlgItem(hDlg,IDC_NEXT),info->currentPage < info->numPages-1);
#endif
			   return TRUE;
			   
		   case IDC_NEXT:
			   if (info->currentPage < info->numPages-1)
				   info->currentPage++;
			   GetPageText(descriptionBuffer,info);
			   Edit_SetText(GetDlgItem(hDlg, IDC_DESCBOX), descriptionBuffer);
			   SetLookPageButtons(hDlg, info);
#if 0
			   EnableWindow(GetDlgItem(hDlg,IDC_PREV),info->currentPage > 0);
			   EnableWindow(GetDlgItem(hDlg,IDC_NEXT),info->currentPage < info->numPages-1);
#endif
			   return TRUE;
			   
		   case IDC_GET:
			   RequestPickup(info->obj->id);
			   EndDialog(hDlg, 0);
			   return TRUE;
			   
		   case IDC_DROP:
			   // Drop all of number items
			   info->obj->temp_amount = info->obj->amount;
			   RequestDrop(info->obj);
			   EndDialog(hDlg, 0);
			   return TRUE;
			   
		   case IDC_USE:
			   // If player isn't holding the object (i.e. there's a Get button), pick object up first
			   if (IsWindowVisible(GetDlgItem(hDlg, IDC_GET)))
				   RequestPickup(info->obj->id);
			   RequestUse(info->obj->id);
			   EndDialog(hDlg, 0);
			   return TRUE;
			   
		   case IDC_UNUSE:
			   RequestUnuse(info->obj->id);
			   EndDialog(hDlg, 0);
			   return TRUE;
			   
		   case IDC_INSIDE:
			   RequestObjectContents(info->obj->id);
			   EndDialog(hDlg, 0);
			   return TRUE;
			   
		   case IDC_ACTIVATE:
			   RequestActivate(info->obj->id);
			   EndDialog(hDlg, 0);
			   return TRUE;
			   
		   case IDC_APPLY:
			   StartApply(info->obj->id);
			   EndDialog(hDlg, 0);
			   return TRUE;
			   
		   case IDC_DESCBOX:
			   if (GET_WM_COMMAND_CMD(wParam, lParam) != EN_CHANGE)
				   break;
			   changed = True;
			   return TRUE;
			   
		   case IDC_URLBUTTON:
			   hURL = GetDlgItem(hDlg, IDC_URL);
			   Edit_GetText(hURL, url, MAX_URL);
			   WebLaunchBrowser(url);
			   return TRUE;
			   
		   case IDOK:
			   
			   // Send new description if changed
			   if (changed)
			   {
				   desc = (char *) SafeMalloc(MAX_DESCRIPTION + 1);
				   GetDlgItemText(hDlg, IDC_DESCBOX, desc, MAX_DESCRIPTION);
				   RequestChangeDescription(info->obj->id, desc);
				   SafeFree(desc);
			   }
			   
			   // Send new URL if changed
			   if (info->url != NULL)
			   {
				   GetDlgItemText(hDlg, IDC_URL, url, MAX_URL);
				   if (strcmp(url, info->url))
					   RequestChangeURL(player.id, url);
			   }
			   
			   // FALLTHRU
			   
		   case IDCANCEL:
			   SetWindowFont(GetDlgItem(hDlg,IDC_DESCNAME), GetFont(FONT_TITLES), FALSE);
			   if (info->hFontTitle && info->hFontTitle != GetFont(FONT_TITLES))
				   DeleteObject(info->hFontTitle);
			   info->hFontTitle = NULL;
			   
			   EndDialog(hDlg, IDOK == GET_WM_COMMAND_ID(wParam, lParam));
			   return TRUE;
      }
      break;
   }
   
   return FALSE;
}
Beispiel #11
0
/*
 * mswin_tw_wm_notify() - WM_NOTIFY handler for textwindows
 */
static LRESULT
mswin_tw_wm_notify(HWND hwnd, int idCtrl, NMHDR *nmhdr)
{
    HWND hwnd_edit = nmhdr->hwndFrom;

    if(nmhdr->code == EN_MSGFILTER)
    {
        MSGFILTER *msg_filter = (MSGFILTER *)nmhdr;

        if(msg_filter->msg == WM_KEYDOWN)
        {
            if(msg_filter->wParam == 'E')
            {
                int control_down = GetKeyState(VK_CONTROL) < 0;
                int shift_down = GetKeyState(VK_SHIFT) < 0;

                // Ctrl+Shift+E toggles the readonly attribute on the text
                //  buffer.
                if(control_down && shift_down)
                    Edit_SetReadOnly(hwnd_edit, !Edit_ExIsReadOnly(hwnd_edit));
                return TRUE;
            }
        }
        else if(msg_filter->msg == WM_CHAR)
        {
            // Only override these keys if this buffer is readonly.
            if(Edit_ExIsReadOnly(hwnd_edit))
            {
                switch(msg_filter->wParam)
                {
                case 'k':
                    SendMessage(hwnd_edit, EM_SCROLL, SB_LINEUP, 0);
                    return TRUE;
                case 'j':
                    SendMessage(hwnd_edit, EM_SCROLL, SB_LINEDOWN, 0);
                    return TRUE;
                case '-':
                case 'b':
                    SendMessage(hwnd_edit, EM_SCROLL, SB_PAGEUP, 0);
                    return TRUE;
                case ' ':
                case 'f':
                    SendMessage(hwnd_edit, EM_SCROLL, SB_PAGEDOWN, 0);
                    return TRUE;
                }
            }
        }
    }
    else if(nmhdr->code == EN_LINK)
    {
        ENLINK *enlink = (ENLINK *)nmhdr;

        if(enlink->msg == WM_LBUTTONDOWN)
        {
            TEXTRANGE tr;
            TCHAR link_buf[1024];

            link_buf[0] = 0;
            tr.lpstrText = link_buf;

            tr.chrg = enlink->chrg;
            if(tr.chrg.cpMax - tr.chrg.cpMin > ARRAYSIZE(link_buf))
                tr.chrg.cpMax = tr.chrg.cpMin + ARRAYSIZE(link_buf);

            SendMessage(hwnd_edit, EM_GETTEXTRANGE, 0, (LPARAM)&tr);
            ShellExecute(hwnd, TEXT("Open"), link_buf, NULL,  NULL,  SW_SHOWNORMAL);
            return TRUE;
        }
    }

    return FALSE;
}
Beispiel #12
0
void WINPropWindowLog::disableLogFile(void)
{
	Edit_SetReadOnly( hLogFileWnd, true );
	Button_Enable( hLogFilePushButtonWnd, false);
}
Beispiel #13
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR cmd, int nCmdShow)
{
    utox_mutex_handle = CreateMutex(NULL, 0, UTOX_TITLE);

    if (!utox_mutex_handle) {
        return 0;
    }

    if (GetLastError() == ERROR_ALREADY_EXISTS) {
        HWND window = FindWindow(UTOX_TITLE, NULL);

        /* uTox is running. */
        if (window) {
            SetForegroundWindow(window);
        }

        return 0;
    }

    MY_CMD_ARGS = cmd;
    MY_HINSTANCE = hInstance;

    TOX_UPDATER_PATH_LEN = GetModuleFileName(NULL, TOX_UPDATER_PATH, MAX_PATH);
    TOX_UPDATER_PATH[TOX_UPDATER_PATH_LEN] = 0;

    {
        char path[MAX_PATH], *s;
        memcpy(path, TOX_UPDATER_PATH, TOX_UPDATER_PATH_LEN + 1);
        s = path + TOX_UPDATER_PATH_LEN;
        while(*s != '\\') {
            s--;
        }

        *s = 0;
        SetCurrentDirectory(path);
    }

    LPWSTR *arglist;
    int argc, i;

    init_tox_version_name();

    /* Convert PSTR command line args from windows to argc */
    arglist = CommandLineToArgvW(GetCommandLineW(), &argc);
    if( NULL != arglist ){
        for (i = 0; i < argc; i++) {
            if(wcscmp(arglist[i], L"--uninstall") == 0) {
                if (is_tox_installed) {
                    uninstall_tox();
                    return 0;
                }
            }
        }
    }

    LOG_FILE = fopen("tox_log.txt", "w");

    /* initialize winsock */
    WSADATA wsaData;
    if(WSAStartup(MAKEWORD(2,2), &wsaData) != 0) {
        LOG_TO_FILE("WSAStartup failed\n");
        return 1;
    }

    if (IsWindowsVistaOrGreater()) {
        /* check if we are on a 64-bit system */
        _Bool iswow64 = 0;
        _Bool (WINAPI *fnIsWow64Process)(HANDLE, _Bool*)  = (void*)GetProcAddress(GetModuleHandleA("kernel32"),"IsWow64Process");
        if(fnIsWow64Process) {
            fnIsWow64Process(GetCurrentProcess(), &iswow64);
        }

        if(iswow64) {
            /* replace the arch in the GET_NAME/TOX_VERSION_NAME strings (todo: not use constants for offsets) */
            GET_NAME[3] = '6';
            GET_NAME[4] = '4';
            TOX_VERSION_NAME[0] = '6';
            TOX_VERSION_NAME[1] = '4';
            LOG_TO_FILE("detected 64bit system\n");
        } else {
            GET_NAME[3] = '3';
            GET_NAME[4] = '2';
            TOX_VERSION_NAME[0] = '3';
            TOX_VERSION_NAME[1] = '2';
            LOG_TO_FILE("detected 32bit system\n");
        }
    } else {
        GET_NAME[3] = 'x';
        GET_NAME[4] = 'p';
        TOX_VERSION_NAME[0] = 'x';
        TOX_VERSION_NAME[1] = 'p';
        LOG_TO_FILE("detected XP system\n");
    }

    /* init common controls */
    INITCOMMONCONTROLSEX InitCtrlEx;

    InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
    InitCtrlEx.dwICC = ICC_PROGRESS_CLASS;
    InitCommonControlsEx(&InitCtrlEx);

    main_window = CreateDialog(MY_HINSTANCE, MAKEINTRESOURCE(IDD_MAIN_DIALOG), NULL, MainDialogProc);

    if (!main_window) {
        LOG_TO_FILE("error creating main window %lu\n", GetLastError());
        exit(0);
    }

    progressbar = GetDlgItem(main_window, ID_PROGRESSBAR);
    set_download_progress(0);
    status_label = GetDlgItem(main_window, IDC_STATUS_LABEL);

    if (!is_tox_installed) {
        // show installer controls
        HWND desktop_shortcut_checkbox = GetDlgItem(main_window, ID_DESKTOP_SHORTCUT_CHECKBOX);
        Button_SetCheck(desktop_shortcut_checkbox, 1);
        ShowWindow(desktop_shortcut_checkbox, SW_SHOW);

        HWND startmenu_shortcut_checkbox = GetDlgItem(main_window, ID_STARTMENU_SHORTCUT_CHECKBOX);
        Button_SetCheck(startmenu_shortcut_checkbox, 1);
        ShowWindow(startmenu_shortcut_checkbox, SW_SHOW);

        HWND start_on_boot_checkbox = GetDlgItem(main_window, ID_START_ON_BOOT_CHECKBOX);
        Button_SetCheck(start_on_boot_checkbox, 1);
        ShowWindow(start_on_boot_checkbox, SW_SHOW);

        ShowWindow(GetDlgItem(main_window, ID_TOX_URL_CHECKBOX), SW_SHOW);

        wchar_t appdatalocal_path[MAX_PATH] = {0};
        if (SHGetFolderPathW(NULL, CSIDL_APPDATA, NULL, 0, appdatalocal_path) == S_OK) {
            set_utox_path(appdatalocal_path);
        }

        Button_Enable(GetDlgItem(main_window, ID_INSTALL_BUTTON), 0);
        ShowWindow(GetDlgItem(main_window, ID_INSTALL_BUTTON), SW_SHOW);

        Edit_SetReadOnly(GetDlgItem(main_window, ID_BROWSE_TEXTBOX), 1);
        ShowWindow(GetDlgItem(main_window, ID_BROWSE_TEXTBOX), SW_SHOW);
        ShowWindow(GetDlgItem(main_window, ID_BROWSE_BUTTON), SW_SHOW);
        ShowWindow(GetDlgItem(main_window, IDC_INSTALL_FOLDER_LABEL), SW_SHOW);
        ShowWindow(main_window, SW_SHOW);
    }

    _beginthread(check_updates, 0, NULL);

    MSG msg;

    while (GetMessage(&msg, NULL, 0, 0) > 0) {
        DispatchMessage(&msg);
    }

    open_utox_and_exit();

    return 0;
}
BOOL TabPage_6_OnCommand(HWND hDlg,WPARAM wParam,LPARAM lParm)
{
	HWND hEdit;

	hEdit = GetDlgItem(hDlg,EditControlID[0]);

	switch(LOWORD(wParam))
	{
		//开始计算(无文本)
	case PCA_START:
		{
			Exception excption;
			ErrNo err;

			PCA pca(hDlg);
			if(err = pca.GetStart_Calc())
			{
				excption.ErrorReport(hDlg,err);
				return FALSE;
			}
		}
		return TRUE;

		// 清除样本数据
	case PCA_DATA_CLEAR:
		Edit_SetText(hEdit,TEXT(""));
		break;

	case PCA_DRAW:
		{
			PCTSTR pErrInfo;

			int n_samples,n_index;
			double **data = NULL;

			TCHAR seps[] = TEXT(" ,\t");
			TCHAR szBuffer[MAXSIZE];
			int graph_type,*sample_num,ncount = 0,nLength;
			Exception excption;
			ErrNo err;

			//获取样本个数
			if(err = GetLine_Int(GetDlgItem(hDlg,EditControlID[2]),n_samples))
			{
				excption.ErrorReport(hDlg,err);
				return err;
			}
			//获取指标个数
			if(err = GetLine_Int(GetDlgItem(hDlg,EditControlID[3]),n_index))
			{
				excption.ErrorReport(hDlg,err);
				return err;
			}
			//获取画图类型
			graph_type = ComboBox_GetCurSel(GetDlgItem(hDlg,ComboBoxID));

			

			//获取样本数据
			//申请空间
			if(!(data = new double* [n_samples]))
			{
				excption.ErrorReport(hDlg,ALLOCATE_MEMORY_FAIL);
				return ALLOCATE_MEMORY_FAIL;
			}
			for(int i=0;i<n_samples;i++)
			{
				if(!(data[i] = new double [n_index]))
				{
					excption.ErrorReport(hDlg,ALLOCATE_MEMORY_FAIL);
					return ALLOCATE_MEMORY_FAIL;
				}
			}
			if(err = GetMatrix(GetDlgItem(hDlg,EditControlID[0]),data,n_samples,n_index))
			{
				excption.ErrorReport(hDlg,err);
				return err;
			}

			//判断是否要将全部样本画在图上
			if(Button_GetCheck(GetDlgItem(hDlg,CheckBoxID)) == BST_CHECKED)		//全部都画
			{
				if(err = PCA_DrawGraph(hDlg,data,List_Names,n_samples,n_index,graph_type))
				{
					excption.ErrorReport(hDlg,err);
					return err;
				}
				
			}
			else			//部分画
			{
				//获取要画图的样本数据编号
				Edit_GetText(GetDlgItem(hDlg,EditControlID[1]),szBuffer,MAXSIZE);

				ncount = 0;
				//判断有多少个样本数据编号
				nLength = _tcslen(szBuffer);
				for(int i=0;i<nLength;i++)
				{
					if(szBuffer[i] == TEXT(','))
						ncount++;
				}
				ncount++;

				//申请空间保存要画图的样本标号
				if(!(sample_num = new int [ncount]))
				{
					excption.ErrorReport(hDlg,ALLOCATE_MEMORY_FAIL);
					return ALLOCATE_MEMORY_FAIL;
				}
				if(err = StringToNumbericArr(szBuffer,seps,sample_num,ncount))
				{
					excption.ErrorReport(hDlg,err);
					return err;
				}
				//判断样本编号是否有误
				for(int i=0;i<ncount;i++)
				{
					if(sample_num[i] > n_samples)
					{
						pErrInfo = excption.FormatError(INCORRECT_DATA);
						_sntprintf_s(szBuffer,_countof(szBuffer),MAXSIZE,TEXT("错误ID:%d\r\n错误信息:%s\r\n补充信息:%s"),INCORRECT_DATA,pErrInfo,TEXT("样本编号超过样本个数"));
						MessageBox(hDlg,szBuffer,TEXT("错误"),MB_ICONERROR);
						return INCORRECT_DATA;
					}
				}

				QuickSort(sample_num,0,ncount-1);		//从小到大

				if(err = PCA_DrawGraph(hDlg,data,List_Names,n_samples,n_index,graph_type,false,sample_num,ncount))
				{
					excption.ErrorReport(hDlg,err);
					return err;
				}

			}
		}
		return TRUE;

	case PCA_NAME:
		{
			HINSTANCE hInstance;
			//创建模态对话框
			hInstance = GetModuleHandle(NULL);
			DialogBox(hInstance,MAKEINTRESOURCE(IDD_PCA_NAME),hDlg,PCA_AddNames_Proc);
		}
		return TRUE;

	case ALL_CHECK:			//要画图的样本数据要全部画在图上
		{
			if(Button_GetCheck(GetDlgItem(hDlg,CheckBoxID)) == BST_CHECKED)
				Edit_SetReadOnly(GetDlgItem(hDlg,EditControlID[1]),TRUE);
			else
				Edit_SetReadOnly(GetDlgItem(hDlg,EditControlID[1]),FALSE);
		}
		return TRUE;

	case RC_CLEAR:
		Edit_SetText(GetDlgItem(hDlg,OutPut_ResultID),TEXT(""));
		return TRUE;

	case RC_HELP:
		{

		}
		return TRUE;
	}
	return FALSE;
}
Beispiel #15
0
Datei: swnd.c Projekt: goriy/sif
void text_read_only (int ro)
{
HWND rtf = hRTF;
  Edit_SetReadOnly (rtf, ro ? TRUE : FALSE);
}
Beispiel #16
0
void CMultiLineEditUI::SetReadOnly(bool bReadOnly)
{
   if( m_pWindow != NULL ) Edit_SetReadOnly(*m_pWindow, bReadOnly == true);
   Invalidate();
}
Beispiel #17
0
/*
 * mswin_set_readonly() - Set readonly status.
 */
void
mswin_set_readonly(MSWIN_TEXTWINDOW *mswin_tw, BOOL read_only)
{
    if(mswin_tw && mswin_tw->hwnd_edit)
        Edit_SetReadOnly(mswin_tw->hwnd_edit, read_only);
}
Beispiel #18
0
/*
 * mswin_tw_wm_command() - WM_COMMAND handler for textwindows
 */
static void
mswin_tw_wm_command(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
    MSWIN_TEXTWINDOW *mswin_tw;

    mswin_tw = (MSWIN_TEXTWINDOW *)(LONG_PTR)GetWindowLongPtr(hwnd, GWLP_USERDATA);

    switch(id)
    {
    case IDM_FILE_CLOSE:
        DestroyWindow(hwnd);
        break;

    case IDM_FILE_PRINT:
        if(mswin_tw->print_callback)
            mswin_tw->print_callback(mswin_tw);
        break;

    case IDM_EDIT_COPY:
        SendMessage(mswin_tw->hwnd_edit, WM_COPY, 0, 0);
        break;

    case IDM_EDIT_CLEAR:
        mswin_tw_clear(mswin_tw);
        break;

    case IDM_EDIT_COPY_APPEND:
    {
        CHARRANGE cr;
        int text_len0, text_len1;
        HWND hwnd_edit = mswin_tw->hwnd_edit;
        BOOL EditIsReadOnly = Edit_ExIsReadOnly(hwnd_edit);

        SetWindowRedraw(hwnd_edit, FALSE);
        Edit_SetReadOnly(hwnd_edit, FALSE);

        // Get current selection.
        SendMessage(hwnd_edit, EM_EXGETSEL, (WPARAM)0, (LPARAM)&cr);

        // Get current length.
        text_len0 = Edit_ExGetTextLen(hwnd_edit, 0);

        // Paste current clip right before our new selection.
        Edit_ExSetSel(hwnd_edit, cr.cpMin, cr.cpMin);
        SendMessage(hwnd_edit, WM_PASTE, 0, 0);

        // Get new length.
        text_len1 = Edit_ExGetTextLen(hwnd_edit, 0);

        // Select new and old clip and copy em.
        Edit_ExSetSel(hwnd_edit, cr.cpMin, cr.cpMax + text_len1 - text_len0);
        SendMessage(hwnd_edit, WM_COPY, 0, 0);

        // Undo our paste and restore original selection.
        SendMessage(hwnd_edit, WM_UNDO, 0, 0);
        SendMessage(hwnd_edit, EM_EXSETSEL, (WPARAM)0, (LPARAM)&cr);

        // Set back to read only.
        Edit_SetReadOnly(hwnd_edit, EditIsReadOnly);
        SetWindowRedraw(hwnd_edit, TRUE);
        break;
    }

    case IDM_EDIT_SEL_ALL:
        Edit_ExSetSel(mswin_tw->hwnd_edit, 0, -1);
        break;
    }
}
/**
 *	@brief	Sets text control editable or uneditable.
 */
void WinTextControlAdapter::MakeEditable(bool isEditable)
{
	Edit_SetReadOnly(hControl, (isEditable) ? FALSE : TRUE);
}