本文整理汇总了C++中CenterWindow函数的典型用法代码示例。如果您正苦于以下问题:C++ CenterWindow函数的具体用法?C++ CenterWindow怎么用?C++ CenterWindow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CenterWindow函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ColorDialogProc
/*
* ColorDialogProc: Allow user to select foreground & background colors.
*/
BOOL CALLBACK ColorDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
static ColorDialogStruct *info;
static HWND hSample;
static COLORREF temp_fg, temp_bg;
int ctrl;
CHOOSECOLOR cc;
HDC hdc;
switch (message)
{
case WM_INITDIALOG:
info = (ColorDialogStruct *) lParam;
temp_fg = GetColor(info->fg);
temp_bg = GetColor(info->bg);
hSample = GetDlgItem(hDlg, IDC_SAMPLETEXT);
CenterWindow(hDlg, hMain);
return TRUE;
case WM_PAINT:
hdc = GetDC(hSample);
SelectPalette(hdc, hPal, FALSE);
SetTextColor(hdc, temp_fg);
SetBkColor(hdc, temp_bg);
InvalidateRect(hSample, NULL, TRUE);
UpdateWindow(hSample);
SelectObject(hdc, GetFont(FONT_TITLES));
TextOut(hdc, 0, 0, szAppName, strlen(szAppName));
ReleaseDC(hSample, hdc);
break;
case WM_COMMAND:
switch(ctrl = GET_WM_COMMAND_ID(wParam, lParam))
{
case IDC_BACKGROUND:
case IDC_FOREGROUND:
memset(&cc, 0, sizeof(CHOOSECOLOR));
cc.lStructSize = sizeof(CHOOSECOLOR);
cc.hwndOwner = hDlg;
cc.rgbResult = (ctrl == IDC_FOREGROUND) ? temp_fg : temp_bg;
cc.lpCustColors = CustColors;
cc.Flags = CC_RGBINIT | CC_FULLOPEN;
if (ChooseColor(&cc) == 0)
return TRUE;
/* Set new color */
if (ctrl == IDC_FOREGROUND)
temp_fg = MAKEPALETTERGB(cc.rgbResult);
else temp_bg = MAKEPALETTERGB(cc.rgbResult);
/* Redraw to see new colors */
InvalidateRect(hDlg, NULL, TRUE);
return TRUE;
case IDOK:
/* Save user's choices */
SetColor(info->fg, temp_fg);
SetColor(info->bg, temp_bg);
MainChangeColor();
EndDialog(hDlg, IDOK);
return TRUE;
case IDCANCEL:
EndDialog(hDlg, IDCANCEL);
return TRUE;
}
}
return FALSE;
}
示例2: ClientMsgBoxProc
/*
* ClientMsgBoxProc: A substitute implementation of MessageBox's window procedure.
* We have 2 OK buttons and 2 Cancel buttons, to account for the case where one
* or the other is the default button. We hide the buttons we don't need.
*/
BOOL CALLBACK ClientMsgBoxProc(HWND hDlg, UINT message, UINT wParam, LONG lParam)
{
static MsgBoxStruct *s;
char *icon = NULL, *temp;
int style, button_style, num_lines, yincrease;
HICON hIcon;
HWND hEdit, hText;
HWND hOK, hCancel, hOK2, hCancel2;
HFONT hFont;
RECT dlg_rect, edit_rect;
switch (message)
{
case WM_ACTIVATE:
CenterWindow(hDlg, GetParent(hDlg));
break;
case WM_SETFOCUS:
case WM_WINDOWPOSCHANGING:
SetFocus(hDlg);
break;
case WM_INITDIALOG:
s = (MsgBoxStruct *) lParam;
button_style = s->style & MB_TYPEMASK;
hText = GetDlgItem(hDlg, IDC_TEXT);
hOK = GetDlgItem(hDlg, IDOK);
hCancel = GetDlgItem(hDlg, IDCANCEL);
hOK2 = GetDlgItem(hDlg, IDOK2);
hCancel2 = GetDlgItem(hDlg, IDCANCEL2);
// Display text
// Put text in invisible edit box to see how much space it will take
hEdit = GetDlgItem(hDlg, IDC_EDIT);
hFont = GetWindowFont(hText);
SetWindowFont(hEdit, hFont, TRUE);
SetWindowFont(hOK, hFont, FALSE);
SetWindowFont(hCancel, hFont, FALSE);
SetWindowFont(hOK2, hFont, FALSE);
SetWindowFont(hCancel2, hFont, FALSE);
SetWindowText(hEdit, s->text);
Edit_GetRect(hEdit, &edit_rect);
num_lines = Edit_GetLineCount(hEdit);
// Count blank lines separately, since edit box not handling them correctly
temp = s->text;
do
{
temp = strstr(temp, "\n\n");
if (temp != NULL)
{
num_lines++;
temp += 2;
}
} while (temp != NULL);
yincrease = GetFontHeight(hFont) * num_lines;
// Resize dialog and text area
GetWindowRect(hDlg, &dlg_rect);
MoveWindow(hDlg, dlg_rect.left, dlg_rect.top, dlg_rect.right - dlg_rect.left,
dlg_rect.bottom - dlg_rect.top + yincrease, FALSE);
ResizeDialogItem(hDlg, hText, &dlg_rect, RDI_ALL, False);
// Move buttons; center OK button if it's the only one
if (button_style == MB_OK)
{
ResizeDialogItem(hDlg, hOK, &dlg_rect, RDI_BOTTOM | RDI_HCENTER, False);
ShowWindow(hCancel, SW_HIDE);
ShowWindow(hCancel2, SW_HIDE);
}
else
{
ResizeDialogItem(hDlg, hOK, &dlg_rect, RDI_BOTTOM, False);
ResizeDialogItem(hDlg, hCancel, &dlg_rect, RDI_BOTTOM, False);
ResizeDialogItem(hDlg, hOK2, &dlg_rect, RDI_BOTTOM, False);
ResizeDialogItem(hDlg, hCancel2, &dlg_rect, RDI_BOTTOM, False);
}
SetWindowText(hDlg, s->title);
SetWindowText(hText, s->text);
ShowWindow(hEdit, SW_HIDE);
// Set icon to appropriate system icon
style = s->style & MB_ICONMASK;
if (style == MB_ICONSTOP)
icon = IDI_HAND;
else if (style == MB_ICONINFORMATION)
icon = IDI_ASTERISK;
else if (style == MB_ICONEXCLAMATION)
icon = IDI_EXCLAMATION;
else if (style == MB_ICONQUESTION)
icon = IDI_QUESTION;
//.........这里部分代码省略.........
示例3: SetFolderPath
BOOL CMainDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetFolderPath();
//skin
CString sSkinPath;
sSkinPath.Format("%s\\skin.bmp",m_sFolderPath);
m_hBmp = (HBITMAP)LoadImage(AfxGetInstanceHandle(),sSkinPath,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
m_bFirst = TRUE;
//inisialisasi database
CString sDBPath;
m_pDb = new CADODatabase();
sDBPath.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%s\\db\\tts.mdb;Persist Security Info=False",m_sFolderPath);
if(m_pDb->Open(sDBPath))
{
//inisialiasi backpropagation
m_backpro.SetConnDB(m_pDb);
//inisialiasi second positioning asymetric windowing
m_spaw.SetConnDB(m_pDb);
m_spaw.SetBackPro(&m_backpro);
m_spaw.Initialize(WINDOWSIZE,CENTERWINDOWPOS,4000,0.01, 0.01,4000);
//inisialisasi speech
//inisialisai natural language
m_NatLang.SetConnDB(m_pDb);
m_NatLang.m_sFolderPath = m_sFolderPath;
m_NatLang.SetSPAW(&m_spaw);
//inisialisasi tiap dialog di memory
m_pLearningDlg = new CLearningDlg;
m_pLearningDlg->SetSPAW(&m_spaw);
m_pLearningDlg->Create( IDD_LEARNING_DIALOG, &m_cMainPanel);
m_pLearningDlg->ShowWindow(SW_HIDE);
m_pKataDlg = new CKataDlg;
m_pKataDlg->SetSPAW(&m_spaw);
m_pKataDlg->SetDB(m_pDb);
m_pKataDlg->Create( IDD_DATA_KATA, &m_cMainPanel);
m_pKataDlg->ShowWindow(SW_HIDE);
m_pPengecualianDlg = new CPengecualianDlg;
m_pPengecualianDlg->SetDB(m_pDb);
m_pPengecualianDlg->Create(IDD_DATA_PENGECUALIAN, &m_cMainPanel);
m_pPengecualianDlg->ShowWindow(SW_HIDE);
m_pSingkatanDlg = new CSingkatanDlg;
m_pSingkatanDlg->SetDB(m_pDb);
m_pSingkatanDlg->Create(IDD_DATA_SINGKATAN,&m_cMainPanel);
m_pSingkatanDlg->ShowWindow(SW_HIDE);
m_pPengucapanDlg = new CNETtalk2Dlg;
m_pPengucapanDlg->SetNatLang(&m_NatLang);
m_pPengucapanDlg->SetConnDB(m_pDb);
m_pPengucapanDlg->Create(IDD_NETTALK2_DIALOG,&m_cMainPanel);
m_pPengucapanDlg->ShowWindow(SW_SHOW);
m_pPengucapanDlg->m_hLearning = m_pLearningDlg->m_hWnd;
m_pPengucapanDlg->m_sFolderpath = m_sFolderPath;
SetActiveDialog(m_pPengucapanDlg);
SetStyle();
}
else
{
MessageBox("Error dalam membuka database","NETtalk2",MB_OK);
EndDialog(0);
}
SetWindowPos(&CWnd::wndTop,0,0,0,0,SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE);
CenterWindow();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
示例4: CenterWindow
INT_PTR CHelpFileMissingDialog::OnInitDialog()
{
CenterWindow(GetParent(m_hDlg),m_hDlg);
return TRUE;
}
示例5: MachineStateDlg_OnInitDialog
/**
* @brief WM_INITDIALOG handler of Machine State dialog.
* @param hwnd - window handle.
* @param hwndFocus - system-defined focus window.
* @param lParam - user-defined parameter.
* @return true to setup focus to system-defined control.
*/
static BOOL MachineStateDlg_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
{
lParam; hwndFocus;
_ASSERTE(g_pResManager != NULL);
if (g_pResManager->m_hBigAppIcon)
SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)g_pResManager->m_hBigAppIcon);
if (g_pResManager->m_hSmallAppIcon)
SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)g_pResManager->m_hSmallAppIcon);
CenterWindow(hwnd, GetParent(hwnd));
g_LayoutMgr.InitLayout(hwnd, g_arrMachineStateLayout, countof(g_arrMachineStateLayout));
HWND hwndProcessList = GetDlgItem(hwnd, IDC_PROCESS_LIST);
ListView_SetExtendedListViewStyle(hwndProcessList, LVS_EX_FULLROWSELECT | LVS_EX_LABELTIP);
HWND hwndModuleList = GetDlgItem(hwnd, IDC_PROCESS_MODULES_LIST);
ListView_SetExtendedListViewStyle(hwndModuleList, LVS_EX_FULLROWSELECT | LVS_EX_LABELTIP);
RECT rcList;
GetClientRect(hwndProcessList, &rcList);
rcList.right -= GetSystemMetrics(SM_CXHSCROLL);
TCHAR szColumnTitle[64];
LVCOLUMN lvc;
ZeroMemory(&lvc, sizeof(lvc));
lvc.mask = LVCF_TEXT | LVCF_WIDTH;
lvc.pszText = szColumnTitle;
lvc.cx = rcList.right / 5;
LoadString(g_hInstance, IDS_COLUMN_PID, szColumnTitle, countof(szColumnTitle));
ListView_InsertColumn(hwndProcessList, CID_PROCESS_ID, &lvc);
lvc.cx = rcList.right * 4 / 5;
LoadString(g_hInstance, IDS_COLUMN_PROCESS, szColumnTitle, countof(szColumnTitle));
ListView_InsertColumn(hwndProcessList, CID_PROCESS_NAME, &lvc);
lvc.cx = rcList.right / 2;
LoadString(g_hInstance, IDS_COLUMN_MODULE, szColumnTitle, countof(szColumnTitle));
ListView_InsertColumn(hwndModuleList, CID_MODULE_NAME, &lvc);
lvc.cx = rcList.right / 4;
LoadString(g_hInstance, IDS_COLUMN_VERSION, szColumnTitle, countof(szColumnTitle));
ListView_InsertColumn(hwndModuleList, CID_MODULE_VERSION, &lvc);
lvc.cx = rcList.right / 4;
LoadString(g_hInstance, IDS_COLUMN_BASE, szColumnTitle, countof(szColumnTitle));
ListView_InsertColumn(hwndModuleList, CID_MODULE_BASE, &lvc);
CEnumProcess::CProcessEntry ProcEntry;
if (g_pEnumProc->GetProcessFirst(ProcEntry))
{
LVITEM lvi;
ZeroMemory(&lvi, sizeof(lvi));
lvi.mask = LVIF_TEXT | LVIF_PARAM;
int iItemPos = 0;
do
{
TCHAR szProcessID[64];
_ultot_s(ProcEntry.m_dwProcessID, szProcessID, countof(szProcessID), 10);
lvi.iItem = iItemPos;
lvi.pszText = szProcessID;
lvi.lParam = ProcEntry.m_dwProcessID;
ListView_InsertItem(hwndProcessList, &lvi);
ListView_SetItemText(hwndProcessList, iItemPos, CID_PROCESS_NAME, ProcEntry.m_szProcessName);
++iItemPos;
}
while (g_pEnumProc->GetProcessNext(ProcEntry));
}
// LVM_SETIMAGELIST resets header control image list
g_ProcessListOrder.InitList(hwndProcessList);
g_ModulesListOrder.InitList(hwndModuleList);
return TRUE;
}
示例6: _T
LRESULT CErrorReportDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
CErrorReportSender* pSender = CErrorReportSender::GetInstance();
CCrashInfoReader* pCrashInfo = pSender->GetCrashInfo();
// Mirror this window if RTL language is in use.
CString sRTL = pSender->GetLangStr(_T("Settings"), _T("RTLReading"));
if(sRTL.CompareNoCase(_T("1"))==0)
{
Utility::SetLayoutRTL(m_hWnd);
}
// Set dialog caption.
SetWindowText(pSender->GetLangStr(_T("MainDlg"), _T("DlgCaption")));
// Center the dialog on the screen.
CenterWindow();
HICON hIcon = NULL;
// Get custom icon.
hIcon = pCrashInfo->GetCustomIcon();
if(hIcon==NULL)
{
// Use default icon, if custom icon is not provided.
hIcon = ::LoadIcon(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_MAINFRAME));
}
// Set window icon.
SetIcon(hIcon, 0);
// Get the first icon in the EXE image and use it for header.
m_HeadingIcon = ExtractIcon(NULL, pCrashInfo->GetReport(0)->GetImageName(), 0);
// If there is no icon in crashed EXE module, use default IDI_APPLICATION system icon.
if(m_HeadingIcon == NULL)
{
m_HeadingIcon = ::LoadIcon(NULL, MAKEINTRESOURCE(IDI_APPLICATION));
}
// Init controls.
m_statSubHeader = GetDlgItem(IDC_SUBHEADER);
m_link.SubclassWindow(GetDlgItem(IDC_LINK));
m_link.SetHyperLinkExtendedStyle(HLINK_COMMANDBUTTON);
m_link.SetLabel(pSender->GetLangStr(_T("MainDlg"), _T("WhatDoesReportContain")));
m_linkMoreInfo.SubclassWindow(GetDlgItem(IDC_MOREINFO));
m_linkMoreInfo.SetHyperLinkExtendedStyle(HLINK_COMMANDBUTTON);
m_linkMoreInfo.SetLabel(pSender->GetLangStr(_T("MainDlg"), _T("ProvideAdditionalInfo")));
m_statEmail = GetDlgItem(IDC_STATMAIL);
m_statEmail.SetWindowText(pSender->GetLangStr(_T("MainDlg"), _T("YourEmail")));
m_editEmail = GetDlgItem(IDC_EMAIL);
m_editEmail.SetWindowText(pSender->GetCrashInfo()->GetPersistentUserEmail());
m_statDesc = GetDlgItem(IDC_DESCRIBE);
m_statDesc.SetWindowText(pSender->GetLangStr(_T("MainDlg"), _T("DescribeProblem")));
m_editDesc = GetDlgItem(IDC_DESCRIPTION);
m_statIndent = GetDlgItem(IDC_INDENT);
m_chkRestart = GetDlgItem(IDC_RESTART);
CString sCaption;
sCaption.Format(pSender->GetLangStr(_T("MainDlg"), _T("RestartApp")), pSender->GetCrashInfo()->m_sAppName);
m_chkRestart.SetWindowText(sCaption);
m_chkRestart.SetCheck(BST_CHECKED);
m_chkRestart.ShowWindow(pSender->GetCrashInfo()->m_bAppRestart?SW_SHOW:SW_HIDE);
m_statConsent = GetDlgItem(IDC_CONSENT);
// Init font for consent string.
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));
lf.lfHeight = 11;
lf.lfWeight = FW_NORMAL;
lf.lfQuality = ANTIALIASED_QUALITY;
_TCSCPY_S(lf.lfFaceName, 32, _T("Tahoma"));
CFontHandle hConsentFont;
hConsentFont.CreateFontIndirect(&lf);
m_statConsent.SetFont(hConsentFont);
// Set text of the static
if(pSender->GetCrashInfo()->m_sPrivacyPolicyURL.IsEmpty())
m_statConsent.SetWindowText(pSender->GetLangStr(_T("MainDlg"), _T("MyConsent2")));
else
m_statConsent.SetWindowText(pSender->GetLangStr(_T("MainDlg"), _T("MyConsent")));
// Init Privacy Policy link
m_linkPrivacyPolicy.SubclassWindow(GetDlgItem(IDC_PRIVACYPOLICY));
m_linkPrivacyPolicy.SetHyperLink(pSender->GetCrashInfo()->m_sPrivacyPolicyURL);
m_linkPrivacyPolicy.SetLabel(pSender->GetLangStr(_T("MainDlg"), _T("PrivacyPolicy")));
BOOL bShowPrivacyPolicy = !pSender->GetCrashInfo()->m_sPrivacyPolicyURL.IsEmpty();
m_linkPrivacyPolicy.ShowWindow(bShowPrivacyPolicy?SW_SHOW:SW_HIDE);
m_statCrashRpt = GetDlgItem(IDC_CRASHRPT);
//.........这里部分代码省略.........
示例7: SetWindowText
BOOL CPrintingDialog::OnInitDialog()
{
SetWindowText(AfxGetAppName());
CenterWindow();
return CDialog::OnInitDialog();
}
示例8: SetDlgItemText
LRESULT CLogTIDFilterEditDlg::OnInitDialog(HWND /*hwndFocus*/, LPARAM /*lp*/)
{
SetDlgItemText(IDC_EDIT_LOGTID, tp::cz(L"%u", m_filter->m_tid));
CenterWindow();
return 0;
}
示例9: SetIcon
BOOL CSettings::OnInitDialog()
{
BOOL bResult = CTreePropSheet::OnInitDialog();
CAppUtils::MarkWindowAsUnpinnable(m_hWnd);
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
if (g_GitAdminDir.HasAdminDir(this->m_CmdPath.GetWinPath()) || g_GitAdminDir.IsBareRepo(this->m_CmdPath.GetWinPath()))
{
CString title;
GetWindowText(title);
SetWindowText(g_Git.m_CurrentDir + _T(" - ") + title);
}
CenterWindow(CWnd::FromHandle(hWndExplorer));
if (this->m_DefaultPage == _T("gitremote"))
{
this->SetActivePage(this->m_pGitRemote);
this->m_pGitRemote->m_bNoFetch = true;
}
else if (this->m_DefaultPage == _T("gitconfig"))
{
this->SetActivePage(this->m_pGitConfig);
}
else if (this->m_DefaultPage == _T("gitcredential"))
{
this->SetActivePage(this->m_pGitCredential);
}
else if (this->m_DefaultPage == _T("main"))
{
this->SetActivePage(this->m_pMainPage);
}
else if (this->m_DefaultPage == _T("overlay"))
{
this->SetActivePage(this->m_pOverlayPage);
}
else if (this->m_DefaultPage == _T("overlays"))
{
this->SetActivePage(this->m_pOverlaysPage);
}
else if (this->m_DefaultPage == _T("overlayshandlers"))
{
this->SetActivePage(this->m_pOverlayHandlersPage);
}
else if (this->m_DefaultPage == _T("proxy"))
{
this->SetActivePage(this->m_pProxyPage);
}
else if (this->m_DefaultPage == _T("diff"))
{
this->SetActivePage(this->m_pProgsDiffPage);
}
else if (this->m_DefaultPage == _T("merge"))
{
this->SetActivePage(this->m_pProgsMergePage);
}
else if (this->m_DefaultPage == _T("alternativeeditor"))
{
this->SetActivePage(this->m_pProgsAlternativeEditor);
}
else if (this->m_DefaultPage == _T("look"))
{
this->SetActivePage(this->m_pLookAndFeelPage);
}
else if (this->m_DefaultPage == _T("dialog"))
{
this->SetActivePage(this->m_pDialogsPage);
}
else if (this->m_DefaultPage == _T("color1"))
{
this->SetActivePage(this->m_pColorsPage);
}
else if (this->m_DefaultPage == _T("color2"))
{
this->SetActivePage(this->m_pColorsPage2);
}
else if (this->m_DefaultPage == _T("color3"))
{
this->SetActivePage(this->m_pColorsPage3);
}
else if (this->m_DefaultPage == _T("save"))
{
this->SetActivePage(this->m_pSavedPage);
}
else if (this->m_DefaultPage == _T("advanced"))
{
this->SetActivePage(this->m_pAdvanced);
}
else if (this->m_DefaultPage == _T("blame"))
{
this->SetActivePage(this->m_pTBlamePage);
}
else if (g_GitAdminDir.HasAdminDir(this->m_CmdPath.GetWinPath()) || g_GitAdminDir.IsBareRepo(this->m_CmdPath.GetWinPath()))
{
this->SetActivePage(this->m_pGitConfig);
}
return bResult;
}
示例10: MoveWindow
BOOL CHttpDownloadDlg::OnInitDialog()
{
//Let the parent class do its thing
CDialog::OnInitDialog();
m_bgImage.LoadFromResource(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP2));
if(!m_bgImage.IsNull())
{
MoveWindow(0,0,m_bgImage.GetWidth(),m_bgImage.GetHeight());
CenterWindow();
}
//Setup the animation control
//m_ctrlAnimate.Open(IDR_HTTPDOWNLOAD_ANIMATION);
m_ctrlAnimate.ShowWindow(SW_HIDE);
m_static.SetMyText("游戏下载");
m_static.MoveWindow(10,40,80,80);
m_listbox.MoveWindow(12,58,410,100);
m_listbox.InitListCtrl(RGB(194,212,234),RGB(0,0,0),RGB(249,175,40),RGB(0,0,0),"");
m_listbox.setProcessPos(2);
m_listbox.SetProcessImage(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP6),MAKEINTRESOURCE(IDB_BITMAP7));
m_listbox.InsertColumn(0,"文件名",LVCFMT_CENTER,130);
m_listbox.InsertColumn(1,"大小(KB)",LVCFMT_CENTER,60);
m_listbox.InsertColumn(2,"进度",LVCFMT_CENTER,170);
m_listbox.InsertColumn(3,"速度",LVCFMT_CENTER,50);
m_listbox.InitListHeader(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP1),MAKEINTRESOURCE(IDB_BITMAP1),RGB(255,255,255),RGB(255,255,255),1);
m_listbox.SetTimer(100,10,NULL);
m_exit.LoadImageFromeResource(AfxGetInstanceHandle(),IDB_BITMAP5);
m_exit.SetPosition(CPoint(410,10));
m_cancel.LoadImageFromeResource(AfxGetInstanceHandle(),IDB_BITMAP4);
m_cancel.SetPosition(CPoint(360,175));
//Validate the URL
ASSERT(m_sURLToDownload.GetLength()); //Did you forget to specify the file to download
if (!AfxParseURL(m_sURLToDownload, m_dwServiceType, m_sServer, m_sObject, m_nPort))
{
//Try sticking "http://" before it
m_sURLToDownload = CString("http://") + m_sURLToDownload;
if (!AfxParseURL(m_sURLToDownload, m_dwServiceType, m_sServer, m_sObject, m_nPort))
{
TRACE(_T("Failed to parse the URL: %s\n"), m_sURLToDownload);
EndDialog(IDCANCEL);
return TRUE;
}
}
//Check to see if the file we are downloading to exists and if
//it does, then ask the user if they were it overwritten
CFileStatus fs;
ASSERT(m_sFileToDownloadInto.GetLength());
if (CFile::GetStatus(m_sFileToDownloadInto, fs))
{/*
CString sMsg;
AfxFormatString1(sMsg, IDS_HTTPDOWNLOAD_OK_TO_OVERWRITE, m_sFileToDownloadInto);
if (AfxMessageBox(sMsg, MB_YESNO) != IDYES)
{
TRACE(_T("Failed to confirm file overwrite, download aborted\n"));
EndDialog(IDCANCEL);
return TRUE;
}*/
}
//Try and open the file we will download into
if (!m_FileToWrite.Open(m_sFileToDownloadInto, CFile::modeCreate | CFile::modeWrite | CFile::shareDenyWrite))
{
TRACE(_T("Failed to open the file to download into, Error:%d\n"), GetLastError());
CString sError;
sError.Format(_T("%d"), ::GetLastError());
CString sMsg;
AfxFormatString1(sMsg, IDS_HTTPDOWNLOAD_FAIL_FILE_OPEN, sError);
//AFCMessageBox(sMsg);
DUIMessageBox(m_hWnd,MB_ICONINFORMATION|MB_OK,"系统提示",false,sMsg);
EndDialog(IDCANCEL);
return TRUE;
}
//Pull out just the filename component
int nSlash = m_sObject.ReverseFind(_T('/'));
if (nSlash == -1)
nSlash = m_sObject.ReverseFind(_T('\\'));
if (nSlash != -1 && m_sObject.GetLength() > 1)
m_sFilename = m_sObject.Right(m_sObject.GetLength() - nSlash - 1);
else
m_sFilename = m_sObject;
m_listbox.InsertItem(0,m_sFilename.GetBuffer());
//Set the file status text
CString sFileStatus;
ASSERT(m_sObject.GetLength());
ASSERT(m_sServer.GetLength());
AfxFormatString2(sFileStatus, IDS_HTTPDOWNLOAD_FILESTATUS, m_sFilename, m_sServer);
m_ctrlFileStatus.SetWindowText(sFileStatus);
//.........这里部分代码省略.........
示例11: sizeof
BOOL CGitProgressDlg::OnInitDialog()
{
__super::OnInitDialog();
// Let the TaskbarButtonCreated message through the UIPI filter. If we don't
// do this, Explorer would be unable to send that message to our window if we
// were running elevated. It's OK to make the call all the time, since if we're
// not elevated, this is a no-op.
CHANGEFILTERSTRUCT cfs = { sizeof(CHANGEFILTERSTRUCT) };
typedef BOOL STDAPICALLTYPE ChangeWindowMessageFilterExDFN(HWND hWnd, UINT message, DWORD action, PCHANGEFILTERSTRUCT pChangeFilterStruct);
CAutoLibrary hUser = AtlLoadSystemLibraryUsingFullPath(_T("user32.dll"));
if (hUser)
{
ChangeWindowMessageFilterExDFN *pfnChangeWindowMessageFilterEx = (ChangeWindowMessageFilterExDFN*)GetProcAddress(hUser, "ChangeWindowMessageFilterEx");
if (pfnChangeWindowMessageFilterEx)
{
pfnChangeWindowMessageFilterEx(m_hWnd, WM_TASKBARBTNCREATED, MSGFLT_ALLOW, &cfs);
}
}
m_ProgList.m_pTaskbarList.Release();
if (FAILED(m_ProgList.m_pTaskbarList.CoCreateInstance(CLSID_TaskbarList)))
m_ProgList.m_pTaskbarList = nullptr;
UpdateData(FALSE);
AddAnchor(IDC_SVNPROGRESS, TOP_LEFT, BOTTOM_RIGHT);
AddAnchor(IDC_TITLE_ANIMATE, TOP_LEFT, BOTTOM_RIGHT);
AddAnchor(IDC_PROGRESSLABEL, BOTTOM_LEFT, BOTTOM_CENTER);
AddAnchor(IDC_PROGRESSBAR, BOTTOM_CENTER, BOTTOM_RIGHT);
AddAnchor(IDC_INFOTEXT, BOTTOM_LEFT, BOTTOM_RIGHT);
AddAnchor(IDCANCEL, BOTTOM_RIGHT);
AddAnchor(IDOK, BOTTOM_RIGHT);
AddAnchor(IDC_LOGBUTTON, BOTTOM_RIGHT);
//SetPromptParentWindow(this->m_hWnd);
m_Animate.Open(IDR_DOWNLOAD);
m_ProgList.m_pAnimate = &m_Animate;
m_ProgList.m_pProgControl = &m_ProgCtrl;
m_ProgList.m_pProgressLabelCtrl = &m_ProgLableCtrl;
m_ProgList.m_pInfoCtrl = &m_InfoCtrl;
m_ProgList.m_pPostWnd = this;
m_ProgList.m_bSetTitle = true;
if (hWndExplorer)
CenterWindow(CWnd::FromHandle(hWndExplorer));
EnableSaveRestore(_T("GITProgressDlg"));
m_background_brush.CreateSolidBrush(GetSysColor(COLOR_WINDOW));
m_ProgList.Init();
int autoClose = CRegDWORD(_T("Software\\TortoiseGit\\AutoCloseGitProgress"), 0);
CCmdLineParser parser(AfxGetApp()->m_lpCmdLine);
if (parser.HasKey(_T("closeonend")))
autoClose = parser.GetLongVal(_T("closeonend"));
switch (autoClose)
{
case 1:
m_AutoClose = AUTOCLOSE_IF_NO_OPTIONS;
break;
case 2:
m_AutoClose = AUTOCLOSE_IF_NO_ERRORS;
break;
default:
m_AutoClose = AUTOCLOSE_NO;
break;
}
return TRUE;
}
示例12: CenterWindow
LRESULT CMainDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
// center the dialog on the screen
CenterWindow();
// set icons
HICON hIcon = (HICON)::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_MAINFRAME),
IMAGE_ICON, ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON), LR_DEFAULTCOLOR);
SetIcon(hIcon, TRUE);
HICON hIconSmall = (HICON)::LoadImage(_Module.GetResourceInstance(), MAKEINTRESOURCE(IDR_MAINFRAME),
IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);
SetIcon(hIconSmall, FALSE);
int nItem = 0;
m_cboThread = GetDlgItem(IDC_THREAD);
nItem = m_cboThread.AddString(_T("Main thread"));
m_cboThread.SetItemData(nItem, 0);
nItem = m_cboThread.AddString(_T("Worker thread"));
m_cboThread.SetItemData(nItem, 1);
m_cboThread.SetCurSel(0);
m_cboExcType = GetDlgItem(IDC_EXCTYPE);
nItem = m_cboExcType.AddString(_T("SEH exception"));
m_cboExcType.SetItemData(nItem, CR_SEH_EXCEPTION);
nItem = m_cboExcType.AddString(_T("terminate"));
m_cboExcType.SetItemData(nItem, CR_CPP_TERMINATE_CALL);
nItem = m_cboExcType.AddString(_T("unexpected"));
m_cboExcType.SetItemData(nItem, CR_CPP_UNEXPECTED_CALL);
nItem = m_cboExcType.AddString(_T("pure virtual method call"));
m_cboExcType.SetItemData(nItem, CR_CPP_PURE_CALL);
nItem = m_cboExcType.AddString(_T("new operator fault"));
m_cboExcType.SetItemData(nItem, CR_CPP_NEW_OPERATOR_ERROR);
nItem = m_cboExcType.AddString(_T("buffer overrun"));
m_cboExcType.SetItemData(nItem, CR_CPP_SECURITY_ERROR);
nItem = m_cboExcType.AddString(_T("invalid parameter"));
m_cboExcType.SetItemData(nItem, CR_CPP_INVALID_PARAMETER);
nItem = m_cboExcType.AddString(_T("SIGABRT"));
m_cboExcType.SetItemData(nItem, CR_CPP_SIGABRT);
nItem = m_cboExcType.AddString(_T("SIGFPE"));
m_cboExcType.SetItemData(nItem, CR_CPP_SIGFPE);
nItem = m_cboExcType.AddString(_T("SIGILL"));
m_cboExcType.SetItemData(nItem, CR_CPP_SIGILL);
nItem = m_cboExcType.AddString(_T("SIGINT"));
m_cboExcType.SetItemData(nItem, CR_CPP_SIGINT);
nItem = m_cboExcType.AddString(_T("SIGSEGV"));
m_cboExcType.SetItemData(nItem, CR_CPP_SIGSEGV);
nItem = m_cboExcType.AddString(_T("SIGTERM"));
m_cboExcType.SetItemData(nItem, CR_CPP_SIGTERM);
nItem = m_cboExcType.AddString(_T("throw C++ typed exception"));
m_cboExcType.SetItemData(nItem, CR_THROW);
nItem = m_cboExcType.AddString(_T("Manual report"));
m_cboExcType.SetItemData(nItem, MANUAL_REPORT);
m_cboExcType.SetCurSel(0);
// register object for message filtering and idle updates
CMessageLoop* pLoop = _Module.GetMessageLoop();
ATLASSERT(pLoop != NULL);
pLoop->AddMessageFilter(this);
pLoop->AddIdleHandler(this);
UIAddChildWindowContainer(m_hWnd);
if(m_bRestarted)
{
PostMessage(WM_POSTCREATE);
}
return TRUE;
}
示例13: EnableStackedTabs
BOOL CTreePropSheet::OnInitDialog()
{
if (m_bTreeViewMode)
{
// be sure, there are no stacked tabs, because otherwise the
// page caption will be to large in tree view mode
EnableStackedTabs(FALSE);
// Initialize image list.
if (m_DefaultImages.GetSafeHandle())
{
IMAGEINFO ii;
m_DefaultImages.GetImageInfo(0, &ii);
if (ii.hbmImage) DeleteObject(ii.hbmImage);
if (ii.hbmMask) DeleteObject(ii.hbmMask);
m_Images.Create(ii.rcImage.right-ii.rcImage.left, ii.rcImage.bottom-ii.rcImage.top, ILC_COLOR32|ILC_MASK, 0, 1);
}
else
m_Images.Create(16, 16, ILC_COLOR32|ILC_MASK, 0, 1);
}
// perform default implementation
BOOL bResult = CPropertySheet::OnInitDialog();
HighColorTab::UpdateImageList(*this);
if (!m_bTreeViewMode)
// stop here, if we would like to use tabs
return bResult;
// Get tab control...
CTabCtrl *pTab = GetTabControl();
if (!IsWindow(pTab->GetSafeHwnd()))
{
ASSERT(FALSE);
return bResult;
}
// ... and hide it
pTab->ShowWindow(SW_HIDE);
pTab->EnableWindow(FALSE);
// Place another (empty) tab ctrl, to get a frame instead
CRect rectFrame;
pTab->GetWindowRect(rectFrame);
ScreenToClient(rectFrame);
m_pFrame = CreatePageFrame();
if (!m_pFrame)
{
ASSERT(FALSE);
AfxThrowMemoryException();
}
m_pFrame->Create(WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS, rectFrame, this, 0xFFFF);
m_pFrame->ShowCaption(m_bPageCaption);
// Lets make place for the tree ctrl
const int nTreeWidth = m_nPageTreeWidth;
const int nTreeSpace = 5;
CRect rectSheet;
GetWindowRect(rectSheet);
rectSheet.right+= nTreeWidth;
SetWindowPos(NULL, -1, -1, rectSheet.Width(), rectSheet.Height(), SWP_NOZORDER|SWP_NOMOVE);
CenterWindow();
MoveChildWindows(nTreeWidth, 0);
// Lets calculate the rectangle for the tree ctrl
CRect rectTree(rectFrame);
rectTree.right = rectTree.left + nTreeWidth - nTreeSpace;
// calculate caption height
CTabCtrl wndTabCtrl;
wndTabCtrl.Create(WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS, rectFrame, this, 0x1234);
wndTabCtrl.InsertItem(0, _T(""));
CRect rectFrameCaption;
wndTabCtrl.GetItemRect(0, rectFrameCaption);
wndTabCtrl.DestroyWindow();
m_pFrame->SetCaptionHeight(rectFrameCaption.Height());
// if no caption should be displayed, make the window smaller in
// height
if (!m_bPageCaption)
{
// make frame smaller
m_pFrame->GetWnd()->GetWindowRect(rectFrame);
ScreenToClient(rectFrame);
rectFrame.top+= rectFrameCaption.Height();
m_pFrame->GetWnd()->MoveWindow(rectFrame);
// move all child windows up
MoveChildWindows(0, -rectFrameCaption.Height());
// modify rectangle for the tree ctrl
rectTree.bottom-= rectFrameCaption.Height();
// make us smaller
CRect rect;
GetWindowRect(rect);
rect.top+= rectFrameCaption.Height()/2;
//.........这里部分代码省略.........
示例14: CenterWindow
LRESULT CColorSetupDlg::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
CenterWindow();
COLORREF BrushColor;
// Windows colors
m_WindowsText.SubclassWindow(GetDlgItem(IDC_BUTTON_WINDOWS_TEXT_COLOR));
m_WindowsText.SetDefaultText(IDS_COLOR_DEFAULT);
m_WindowsText.SetDefaultColor(m_clDefTextColor);
m_WindowsText.SetColor((m_clWindowsText != CLR_NONE)? m_clWindowsText : CLR_DEFAULT);
m_WindowsBack.SubclassWindow(GetDlgItem(IDC_BUTTON_WINDOWS_BACK_COLOR));
m_WindowsBack.SetDefaultText(IDS_COLOR_DEFAULT);
m_WindowsBack.SetDefaultColor(m_clDefBackColor);
m_WindowsBack.SetColor(BrushColor = ((m_clWindowsBack != CLR_NONE) ? m_clWindowsBack : CLR_DEFAULT));
if (BrushColor == CLR_DEFAULT)
{
BrushColor = m_clDefBackColor;
}
m_WindowsBrush.CreateSolidBrush(BrushColor);
//Command Colors
m_CommandText.SubclassWindow(GetDlgItem(IDC_BUTTON_COMMAND_TEXT_COLOR));
m_CommandText.SetDefaultText(IDS_COLOR_DEFAULT);
m_CommandText.SetDefaultColor(m_clDefTextColor);
m_CommandText.SetColor((m_clCommandText != CLR_NONE) ? m_clCommandText : CLR_DEFAULT);
m_CommandBack.SubclassWindow(GetDlgItem(IDC_BUTTON_COMMAND_BACK_COLOR));
m_CommandBack.SetDefaultText(IDS_COLOR_DEFAULT);
m_CommandBack.SetDefaultColor(m_clDefBackColor);
m_CommandBack.SetColor(BrushColor = ((m_clCommandBack != CLR_NONE) ? m_clCommandBack : CLR_DEFAULT));
if (BrushColor == CLR_DEFAULT)
{
BrushColor = m_clDefBackColor;
}
m_CommandBrush.CreateSolidBrush(BrushColor);
//Notify Colors
m_NotifyText.SubclassWindow(GetDlgItem(IDC_BUTTON_NOTIFY_TEXT_COLOR));
m_NotifyText.SetDefaultText(IDS_COLOR_DEFAULT);
m_NotifyText.SetDefaultColor(m_clDefTextColor);
m_NotifyText.SetColor((m_clNotifyText != CLR_NONE) ? m_clNotifyText : CLR_DEFAULT);
m_NotifyBack.SubclassWindow(GetDlgItem(IDC_BUTTON_NOTIFY_BACK_COLOR));
m_NotifyBack.SetDefaultText(IDS_COLOR_DEFAULT);
m_NotifyBack.SetDefaultColor(m_clDefBackColor);
m_NotifyBack.SetColor(BrushColor = ((m_clNotifyBack != CLR_NONE) ? m_clNotifyBack : CLR_DEFAULT));
if (BrushColor == CLR_DEFAULT)
{
BrushColor = m_clDefBackColor;
}
m_NotifyBrush.CreateSolidBrush(BrushColor);
//Reflect Colors
m_ReflectText.SubclassWindow(GetDlgItem(IDC_BUTTON_REFLECT_TEXT_COLOR));
m_ReflectText.SetDefaultText(IDS_COLOR_DEFAULT);
m_ReflectText.SetDefaultColor(m_clDefTextColor);
m_ReflectText.SetColor((m_clReflectText != CLR_NONE) ? m_clReflectText : CLR_DEFAULT);
m_ReflectBack.SubclassWindow(GetDlgItem(IDC_BUTTON_REFLECT_BACK_COLOR));
m_ReflectBack.SetDefaultText(IDS_COLOR_DEFAULT);
m_ReflectBack.SetDefaultColor(m_clDefBackColor);
m_ReflectBack.SetColor(BrushColor = ((m_clReflectBack != CLR_NONE) ? m_clReflectBack : CLR_DEFAULT));
if (BrushColor == CLR_DEFAULT)
{
BrushColor = m_clDefBackColor;
}
m_ReflectBrush.CreateSolidBrush(BrushColor);
return 1; // Let the system set the focus
}
示例15: CFG_MainProc
LRESULT CALLBACK CFG_MainProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
{
g_tvIndexCFG = 0;
g_hwndTree = GetDlgItem(hDlg,IDC_TREE_CONF);
SendMessage(g_hwndTree, TVM_SETIMAGELIST , TVSIL_NORMAL, (LPARAM)g_hImageListIcons);
SendMessage(g_hwndTree, TVM_SETIMAGELIST , TVSIL_STATE, (LPARAM)g_hImageListStates);
HTREEITEM hNewItem;
hNewItem = TreeView_AddItem(27,g_lang.GetString("ConfigGeneral"));
hNewItem = TreeView_AddItem(15,g_lang.GetString("ConfigMinimizer"));
hNewItem = TreeView_AddItem(28,"mIRC");
hNewItem = TreeView_AddItem(3,"Account (XMPP)");
hNewItem = TreeView_AddItem(16,g_lang.GetString("ConfigExtExe"));
hNewItem = TreeView_AddItem(25,g_lang.GetString("ConfigGraphic"));
hNewItem = TreeView_AddItem(13,g_lang.GetString("ConfigNetwork"));
hNewItem = TreeView_AddItem(20 ,g_lang.GetString("ConfigGames"));
if (hNewItem)
TreeView_Select(g_hwndTree, hNewItem, TVGN_CARET);
for(UINT i=0;i<gm.GamesInfo.size();i++)
hNewItem = TreeView_AddItem(gm.GamesInfo[i].iIconIndex,gm.GamesInfo[i].szGAME_SHORTNAME);
TreeView_Select(g_hwndTree, NULL, TVGN_CARET);
for(UINT i=0; i<gm.GamesInfo.size();i++)
{
GamesInfoCFG[i].bActive = gm.GamesInfo[i].bActive;
GamesInfoCFG[i].bUseHTTPServerList[0] = gm.GamesInfo[i].bUseHTTPServerList[0];
GamesInfoCFG[i].dwMasterServerPORT = gm.GamesInfo[i].dwMasterServerPORT;
strcpy(GamesInfoCFG[i].szGAME_NAME, gm.GamesInfo[i].szGAME_NAME);
strcpy(GamesInfoCFG[i].szMasterServerIP[0], gm.GamesInfo[i].szMasterServerIP[0]);
GamesInfoCFG[i].vGAME_INST = gm.GamesInfo[i].vGAME_INST;
}
memcpy(&AppCFGtemp,&AppCFG,sizeof(APP_SETTINGS_NEW));
CFG_g_sMIRCoutputTemp = g_sMIRCoutput;
SetDlgItemText(hDlg,IDOK,g_lang.GetString("Ok"));
SetDlgItemText(hDlg,IDC_BUTTON_DEFAULT,g_lang.GetString("SetDefault"));
SetDlgItemText(hDlg,IDCANCEL,g_lang.GetString("Cancel"));
CenterWindow(hDlg);
CFG_OnTabbedDialogInit(hDlg) ;
return TRUE;
}
case WM_NOTIFY:
{
NMTREEVIEW *lpnmtv;
lpnmtv = (LPNMTREEVIEW)lParam;
switch (wParam)
{
case IDC_TREE_CONF:
{
NMTREEVIEW *pnmtv;
pnmtv = (LPNMTREEVIEW) lParam;
if((lpnmtv->hdr.code == TVN_SELCHANGED) )
{
if((g_bChanged==true) && (pnmtv->action == TVC_BYMOUSE))
CFG_ApplySettings();
CFG_OnSelChanged(hDlg);
}
}
break;
}
break;
}
case WM_COMMAND:
{
switch (LOWORD(wParam))
{
case IDCANCEL:
LocalFree(g_pHdr);
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
case IDOK:
{
CFG_ApplySettings();
if(AppCFGtemp.bAutostart)
AddAutoRun(EXE_PATH);
else
RemoveAutoRun();
if(AppCFGtemp.bUse_minimize)
{
UnregisterHotKey(NULL, HOTKEY_ID);
if (!RegisterHotKey(NULL, HOTKEY_ID, AppCFGtemp.dwMinimizeMODKey ,AppCFGtemp.cMinimizeKey))
{
//probably already registred
MessageBox(NULL,g_lang.GetString("ErrorRegHotkey"),"Hotkey error",NULL);
}
//.........这里部分代码省略.........