|
Hi all,
I have used wizard mode propertysheet,font of all property pages not change form dialog box property so i m using this to change font of property pages.
font is changed now,but the property page not fit to property sheet,i mean the property page not fully visible.
my code is.
extern CFont fArial,fArial1;
enum { CDF_CENTER, CDF_TOPLEFT, CDF_NONE };
void ChangeDialogFont(CWnd* pWnd, CFont* pFont, int nFlag)
{
CRect windowRect;
TEXTMETRIC tmOld, tmNew;
CDC * pDC = pWnd->GetDC();
CFont * pSavedFont = pDC->SelectObject(pWnd->GetFont());
pDC->GetTextMetrics(&tmOld);
pDC->SelectObject(pFont);
pDC->GetTextMetrics(&tmNew);
pDC->SelectObject(&fArial);
pWnd->ReleaseDC(pDC);
long oldHeight = tmOld.tmHeight+tmOld.tmExternalLeading;
long newHeight = tmNew.tmHeight+tmNew.tmExternalLeading;
if (nFlag != CDF_NONE)
{
CRect clientRect, newClientRect, newWindowRect;
pWnd->GetWindowRect(windowRect);
pWnd->GetClientRect(clientRect);
long xDiff = windowRect.Width() - clientRect.Width();
long yDiff = windowRect.Height() - clientRect.Height();
newClientRect.left = newClientRect.top = 0;
newClientRect.right = clientRect.right * tmNew.tmAveCharWidth / tmOld.tmAveCharWidth;
newClientRect.bottom = clientRect.bottom * newHeight / oldHeight;
if (nFlag == CDF_TOPLEFT)
{
newWindowRect.left = windowRect.left;
newWindowRect.top = windowRect.top;
newWindowRect.right = windowRect.left + newClientRect.right + xDiff;
newWindowRect.bottom = windowRect.top + newClientRect.bottom + yDiff;
}
else if (nFlag == CDF_CENTER)
{
newWindowRect.left = windowRect.left -
(newClientRect.right - clientRect.right)/2;
newWindowRect.top = windowRect.top -
(newClientRect.bottom - clientRect.bottom)/2;
newWindowRect.right = newWindowRect.left + newClientRect.right + xDiff;
newWindowRect.bottom = newWindowRect.top + newClientRect.bottom + yDiff;
}
pWnd->MoveWindow(newWindowRect);
}
pWnd->SetFont(pFont);
CWnd* pChildWnd = pWnd->GetWindow(GW_CHILD);
while (pChildWnd)
{
pChildWnd->SetFont(pFont);
pChildWnd->GetWindowRect(windowRect);
CString strClass;
::GetClassName(pChildWnd->m_hWnd, strClass.GetBufferSetLength(32), 31);
strClass.MakeUpper();
if(strClass==_T("COMBOBOX"))
{
CRect rect;
pChildWnd->SendMessage(CB_GETDROPPEDCONTROLRECT,0,(LPARAM) &rect);
windowRect.right = rect.right;
windowRect.bottom = rect.bottom;
}
pWnd->ScreenToClient(windowRect);
windowRect.left = windowRect.left * tmNew.tmAveCharWidth / tmOld.tmAveCharWidth;
windowRect.right = windowRect.right * tmNew.tmAveCharWidth / tmOld.tmAveCharWidth;
windowRect.top = windowRect.top * newHeight / oldHeight;
windowRect.bottom = windowRect.bottom * newHeight / oldHeight;
pChildWnd->MoveWindow(windowRect);
pChildWnd = pChildWnd->GetWindow(GW_HWNDNEXT);
}
}
than on OnInitDialog() function
fArial.CreateFont(
16,
0,
0,
0,
FW_BOLD,
FALSE,
FALSE,
0,
ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH | FF_SWISS,
_T("Verdana"));
fArial1.CreateFont(
13,
0,
0,
0,
FALSE,
FALSE,
FALSE,
0,
ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH | FF_SWISS,
_T("Verdana"));
CPropertyPage* pPage = GetActivePage ();
ASSERT (pPage);
ChangeDialogFont (this, &fArial1, CDF_CENTER);
for (int iCntr = 0; iCntr < GetPageCount (); iCntr++)
{
VERIFY (SetActivePage (iCntr));
CPropertyPage* pPage = GetActivePage ();
ASSERT (pPage);
ChangeDialogFont (pPage, &fArial1, CDF_CENTER);
}
VERIFY (SetActivePage (pPage));
CTabCtrl* pTab = GetTabControl ();
ASSERT (pTab);
if (m_psh.dwFlags & PSH_WIZARD)
{
pTab->ShowWindow (SW_HIDE);
GetClientRect (&m_rctPage);
CWnd* pButton = GetDlgItem (ID_WIZBACK);
ASSERT (pButton);
CRect rc;
pButton->GetWindowRect (&rc);
ScreenToClient (&rc);
m_rctPage.bottom = rc.top-2;
}
else
{
pTab->GetWindowRect (&m_rctPage);
ScreenToClient (&m_rctPage);
pTab->AdjustRect (FALSE, &m_rctPage);
}
pPage->MoveWindow (&m_rctPage);
please help me for this.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
I'm not wading through all that!
But I can imagine the problem. The wizard needs to calculate the size of the dialog before creation, so it can create itself first, large enough for your ends.
Reading the PROPSHEETPAGE structure, it has a PSP_PREMATURE flag. That implies that the normal behaviour is to wait until the correct tab / next button is pressed before the page is corrected.
I can see two choices:
1) Use the PSP_PREMATURE flag, and hope that makes the calculations work on the actual window, rather than reading the dialog template.
2) Load the resource into R/W ram, change the font field, and use the PSP_DLGINDIRECT flag of the PROPSHEEYPAGE. Not an easy choice...
Good luck,
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
I want to use CToolBar in a doc/view based project. when i set corresponding images for the toolbar, i found that the height of the bottons is not as high as the toolbar. so, how to make them as high as its parent(ToolBar)?
If i implement it by ownerdraw, i fond, there would be more issues to deal.
Any ideas?
|
|
|
|
|
I noticed that there are some differences between MS C++ and C++ that is used elsewhere, for example most tutorials available on the internet are in "normal" C++.
Are the commands so differnt that you need to learn one or the other or are they similar enough that if you leanr one, you know both?
I'm currently stuck in a class about MS C++ nad I don't have any poosibility to learn the "normal" C++.
When I'm done (3 months) will I also be able to programm with the "normal" C++ or would I have to learn that again?
If so, how long would it take (realistically) to switch from MS C++ to the "normal" one?
Thanks in advance.
|
|
|
|
|
Microsoft simply provides certain extensions to the C++ standard.
These extensions are MS specific and will work only with MS compilers and OSs.
Don't worry about learning one over the other. They're almost the same.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
They are practically the same for almost all purposes.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks.
Though I noticed in MS C++ you cannot use cin /cout , the syntax for #include is different and strings are also handled differenty.
|
|
|
|
|
Megidolaon wrote:
Though I noticed in MS C++ you cannot use cin/cout,
That's not true.
Megidolaon wrote: the syntax for #include is different and strings are also handled differenty.
That is, as well, not true.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
i think cin/cout can be used in ms c++,once i tried.Maybe you didn't include the right head files.or some thing wrong with the name spaces
|
|
|
|
|
You can certainly use any cin/cout in ms c++, .. u have to include iostream.
kamalesh
|
|
|
|
|
Megidolaon wrote:
Though I noticed in MS C++ you cannot use cin/cout, the syntax for #include is different and strings are also handled differenty.
It's not that. In pre-standard C++, it would be like
#include <iostream.h>
After standardization its,
#include <iostream>
Moreover I can say you forgot to include "using namespace std".
|
|
|
|
|
grassrootkit wrote: Moreover I can say you forgot to include "using namespace std".
yeah, but using prepending std:: is generally prefered (the using namespace command can lead to unresovled names and should be used with care...
|
|
|
|
|
When you say "MS" you are potentially targeting windows. It's totally different from standard C++. Though you get the standard C++ from MS compilers, MS C++ (in your terms) or VC++ (the right term) would mean more eg: Win32APIs, MFC etc all platform oriented. All these libraries/Frameworks make things on top of MS C++ compiler.If you develop apps using plain, Standard C++, you will be able to run it on any OS. Just a recompilation would do.
|
|
|
|
|
you are obviously totally confused.
recent Microsoft C++ Compiler (above version 2003) are significantly closer to the standard C++ than previous ones.
so you can write a totally standard C++ Application (say, under vi or notepad, why not), and compile it with any compiler. gcc would handle it, and VC++ as well.
what makes you becoming non-standard C++ is by using compiler-specific commands, or non-portable libraries (such as Win32, MFC)...
but remember that VC++ only provides extensions to the standard, so anything standard should work with a Visual C++ compiler. If it doesn't, you're probably doing it wrong (show your code about cin /cout /#include )...!
However, as an example, the following is 100% standard C++:
<font color="blue">#include</font> <iostream>
<font color="blue">#include</font> <string>
<font color="blue">void</font> main(<font color="blue">void</font>) {
std::string strName = <font color="gray">""</font>;
<font color="green">
std::cout << <font color="gray">"your name: "</font>;
std::cin >> strName;
<font color="green">
std::cout << <font color="gray">"Hello "</font> << strName << <font color="gray">" !"</font> << endl;
}
modified on Monday, February 23, 2009 8:00 AM
|
|
|
|
|
Thanks.
you are obviously totally confused.
Yes, I was, but now I'm not anymore.
Almost all online tutorials I found were in standard C++ and never mentioned anything about VC++, so I assumed there'd be sigificant differences.
Thus I never found that you need #include <iostream></iostream> to make it work in VC++, I just tried it out and it works fine.
Without that, I always got an error with using std; .
As for other OS, it should be fine if I don't get too much into the MS specific libraries?
|
|
|
|
|
Megidolaon wrote: Thus I never found that you need #include to make it work in VC++, I just tried it out and it works fine.
Without that, I always got an error with using std;.
becasue you probably used it badly.
can you post a code sample of a "not compiling" code, and the associated error ?
We'll tell you what's wrong then...
Megidolaon wrote: As for other OS, it should be fine if I don't get too much into the MS specific libraries?
As far as you do command line applications, everything will be ok.
unfortunately, as soon as you start a windowed application, you'll have to choose a graphical library, which is most of the time OS-specific...
But you know, it's not a bad choice sometimes to move a little from the standard C++ paths, especially for things that are anyway specifics to the OS.
But for the logical layers, all depends on what systems you target, but I personnally prefer staying standard as much as I can...
|
|
|
|
|
https://forum.codejock.com/forum_posts.asp?TID=6186[^]
i have the same problem like above link.
OnCtlColor not working in property sheet and the background of controls not colred.
here one solution is given but i cant understand this.please explain me with example
and please give me any other solution to solve my problem.
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
Didn't you ask this question a couple of days ago, and I suggested looking for the WM_CTLCOLOR message (and its cousins) using Spy++ tool? I don't remember you replying to my suggestion.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Hi All
How can i get Device ID of Removal Device?PLz help me
|
|
|
|
|
You should be able to get that from the lParam parameter of the WM_DEVICECHANGE message when the wParam parameter is DBT_DEVICEREMOVECOMPLETE .
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
|
how to draw transparent rectangle in MFC
I have tried using following code but it does not work.
int nPrevMode = pDC->SetBkMode(TRANSPARENT);
COLORREF bkcolor = pDC->SetBkColor(BLACK);
pDC->Rectangle(rect1.left, rect1.top, rect1.right, rect1.bottom);
thanks
|
|
|
|
|
Use CDC::FrameRect[^] or use CDC::Rectangle[^] with a NULL_BRUSH[^].
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
saksp wrote: does not work.
Define what you expected to happen and what actually happened. I suspect your expectation doesn't match what the documentation promises.
The documentation of SetBkMode says this:
The background mix mode is used with text, hatched brushes, and pen styles that are not solid lines.
Are you using any of those three?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
do you mean you need a frame not filled with any clour?
if so,framerect may help you.
|
|
|
|
|