|
I'm in the middle of writing a control which will show some text.
Now, if I just output the text using DrawText, my text is displayed using the default font, which is Arial bold I think.
But I want to use the font that is used in a static control. This font is much smaller and not bold.
I am able to use this font using CreateFont.
But what if Ms decides to use a different font in a future version. This means I have to change my control to use a different font.
What would be nice is if I should have a function that can determine the default font used for a static control. I looked on msdn but can't find such a function.
So does anybody know if there is such a thing as GetSystemMetrics but then for fonts?
Thanks
Wim
|
|
|
|
|
WTL has a ATLGetDefaultGuiFont( ) which uses ::GetStockObject( DEFAULT_GUI_FONT ). I think this might be what you are looking for. Otherwise you could always require the users of your control to do a
<br />
m_wndMyControl.SetFont( GetFont( ) );<br />
after your control has been Create'd/Sublcass'ed, assuming m_wndMyControl is a member variable in a dialog - GetFont( ) returns the font of the dialog.
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
I have:
POSITION pos1 = pDoc->GetFirstViewPosition();
while (pos1!=NULL)
{
CView* pView = pDoc->GetNextView(pos1);
ASSERT_VALID(pView);
The app starts with View1 showing(there are two views only). View2 hasnt been spawned yet (view1 spawns it). In this case I expected pView to be NULL. But this code snippet I have will not like NULL. But it doesnt crash at this ASSERT ever.
2. The weird thing: I stepped in, and even though view2 wasnt created, pView came out to be non NULL (pos1 gets set to NULL though as expected) SO how come pView is nonNULL for a view that isnt even there? Or does the doc know that it has two views even if View2 hasnt been spawned yet?
Appreciate your help,
ns
|
|
|
|
|
According to your description it behaves correctly. On the first run, pView receives the pointer to the View1 which IS created, then pos1 is set to NULL, indicating that there is no more view to enumerate.
Where is the problem? Is it the GetNextView() call? If it starts at the begin, then the next is the first in the list.
I keep submitting “VB” as a Priority-1 bug, but apparently no one here knows how to fix it. Nick Hodapp, Semicolon
|
|
|
|
|
Oh I see now. I thought that the first view was dealt with already outside the while, and in actuality its just pointing to the start of all the views....thanks for clearing it up for me!
Appreciate your help,
ns
|
|
|
|
|
pView will be pointing to the first view for that document which is of type view1. To check this expand the pView pointer in the debug window and see what the RUNTIME_CLASS information is. What you describe happening is exactly what should happen in the case described.
pos1 is an iterator which gets set to start of list
pos1 get incremented to NULL (no more elements) when you get the view1 pointer, it would goto non NULL if another view (view2) was in the view list, but its not.
Roger Allen
Sonork 100.10016
I have a terminal disease. Its called life!
|
|
|
|
|
Thanks for the debug window RUNTIME_CLASS idea. I hadnt thought of that.
Appreciate your help,
ns
|
|
|
|
|
Hi guys
It is possible to print more than one page inside OnPrint?
I try pDC->StartPage() and pDC->EndPage() and always receive a -1 as return value.
I'm doing something wrong?
Cheers
Doctorpi
|
|
|
|
|
Well, you could do it like that, but you would have to do it:
pDC->EndPage();
pDC->StartPage();
OnPrepareDC(pDC);
.. rest of printing code.
What you really need to do is to set the CPrintInfo max_page value to the number of pages you want to print. In OnPreparePrinting() you need to call pInfo->SetMaxPage(x). Your OnPrint() procedure will then be called once for every page to be printed. You should check the value of pInfo->m_nCurPage to see which page of output you need to draw.
Roger Allen
Sonork 100.10016
I have a terminal disease. Its called life!
|
|
|
|
|
Yes, I concur. I have written a series of applications which produce bills (mainly for solicitors, or for the non-UK reader, lawyers). As you might imagine, these can often (all too often) be multiple pages. Some of them are for claiming from the Legal Aid Board, so have a rigid format, while others are more free-form in content.
The way I do this is to generate a list of printing objects, each of which knows the page it is to be printed on (my base CPrintObject has a PageNum() member). I go through on OnPreparePrinting and generate this list, then the last object in the list has my final page number.
This can be used in SetMaxPage(), and then in OnPrint, I just go through the list and for each object where PageNum() == pInfo->m_nCurPage, I invoke the object's Print method.
This works fine, and allows you to honour page number selection from the print dialog and so on.
The only issue I found was that the preview looked terrible, presumably because the preview view was getting confused about the font selection/deselection that was taking place, so I output to a memory DC then blit the result, which tidied it up at the expense of taking longer.
Steve S
[This signature space available for rent]
|
|
|
|
|
I call the FindText SDK function to open a modeless "Find / Replace" dialog.
I have defined some keys with accelerators (like 'S', ...) in my application.
So, the problem is that the modeless "Find / Replace" dialog do not get this keys - the main application get the keys!
How to fix???
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
Override the dialog PreTranslateMessage( ). If the accelerator keys are defined in the main accelerator table you could use this code inside PreTranslateMessage:
<br />
<br />
if ( pMsg->message == WM_KEYFIRST && pMsg->message <= WM_KEYLAST )<br />
{<br />
CWnd* pMainWnd = AfxGetMainWnd( );<br />
if ( pMainWnd != NULL )<br />
{<br />
HACCEL hAccel = static_cast< CFrameWnd* >( pMainWnd )->GetDefaultAccelerator( );<br />
if ( hAccel != NULL && ::TranslateAccelerator( pMainWnd->GetSafeHwnd( ), hAccel, pMsg ) )<br />
{<br />
return TRUE;<br />
}<br />
}<br />
}<br />
<br />
return CDialog::PreTranslateMessage( pMsg );<br />
<br />
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
Thanks! I will try it!
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
Hi,
I'm trying to add bitmaps to the menu in my vc++6 app.
The problem is that my bitmaps have a purple background and this is displayed in the menu. How do i load a bitmap and set a color to transparency?
cheers
Asim Hussain
e: asim@jawache.net
w: www.jawache.net
|
|
|
|
|
You need to do a transparent blit into a bitmap-dc. W2K and up have a API-fkt doing this. Older Windows have to emulate that via several blits using a sequence of ROPs.
I found such a routine on codeguru*duck under the knife thrown*.
Alternatively, the function AfxLoadSysColorBitmap() might do what you want. It is in afxext.h .
|
|
|
|
|
Hi everybody,
A question with regards the above. How does one show the X-axis label and the Y-axis label? Not the axis values.
In other words the x-axis label could be something like:
Time (hours)
Thanks
Regards
Rui
|
|
|
|
|
I'm creating a MDI application which creates a context menu by re-using a menu from the parent frame. This works fine when the child frame is not maximised. But when the child frame is maximised I get the wrong menu. i.e instead of getting the 4th item in the menu, it gets the 5th when maximised. This is not really true, as I notice that an icon is inserted as the 0th item in the menu when maximised. ie
restore view:
MENU
0th = File, 1st = Edit, 2nd = View, 3rd = Model
maximised view
MENU
0th = ICON, 1st = File, 2nd = Edit, 3rd = View, 4th = Model
The code I've used for my context menu is shown below
CMDIFrameWnd *pMainFrame = GetMDIFrame();
CMenu *pMenu = pMainFrame->GetMenu();
pMenu = pMenu->GetSubMenu(3);
pMenu->TrackPopupMenu(TPM_LEFTALIGN + TPM_LEFTBUTTON, point.x, point.y, this, NULL);
any please would be appreciated
|
|
|
|
|
You could use CMenu::GetMenuItemCount() to determine whether to get the 3rd or 4th submenu.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
thx for the tip, the menu count method fix the problem. But I've decide the use the GetWindowPlacement() function to get the state of the child window, which is more general I think
CMDIFrameWnd *pMainFrame = GetMDIFrame();
CMenu *pMenu = pMainFrame->GetMenu();
WINDOWPLACEMENT wp;
GetWindowPlacement(&wp);
if (wp.showCmd == SW_SHOWMAXIMIZED)
pMenu = pMenu->GetSubMenu(4);
else
pMenu = pMenu->GetSubMenu(3);
pMenu->TrackPopupMenu(TPM_LEFTALIGN + TPM_LEFTBUTTON, point.x, point.y, this, NULL);
|
|
|
|
|
If I have this decimal number (Base 10) where the maximum value is 256, and I want to convert that to a hexidecimal in unsigned char format.
<br />
data[0] = 154;
data[1] = 203;
data[2] = 15;
data[3] = 54;
data[4] = 248;
data[5] = 175;
and I want to change data(base 256) to Ctring which have format in base 16 character
<br />
unsigned char *m_data;<br />
<br />
and I want <br />
m_data = "9ACB0F38F8AF";<br />
Do you know how to do that?
|
|
|
|
|
Didn't you just ask this question earlier? You can use the CString Format() member function.
If you need an unsigned character array instead of a CString class you can simply use the (LPCTSTR) cast operator to retrieve the pointer and then cast it to an unsigned char * pointer.
I suspect your asking this question again because your using C and not C++. You really need to put more information in your questions, if you expect to get your question answered correctly. If your using C, then you would use the sprintf() function which has the same functionality of Format(). Get a C book or search for sprinf() on the web!
<br />
sprintf(m_data, "%2H%2H%2H..",data[0], data[1].......<br />
- Anatari
|
|
|
|
|
Anatari wrote:
suspect your asking this question again because your using C and not C++. You really need to put more information in your questions, if you expect to get your question answered correctly.
He he, I couldn't agree more. Probably these guys have never done any kind of useful bug reporting in their whole lives.
The bad thing is, it's my experience that trying to teach posters to better ask questions only made me have an insult in return...
Back to real work : D-25.
|
|
|
|
|
Not to mention the high probability that we're helping the kid do his homework...
Software Zen: delete this;
|
|
|
|
|
CString strOutput;
int nNumDataItems = 6;
for (int nData=0; (nData < nNumDataItems); nData++) {
CString strHex;
strHex.Format ("%0X", data[nData]);
strOutput += strHex;
}
or
char szOutput [256];
strcpy (szOutput, "");
int nNumDataItems = 6;
for (int nData=0; (nData < nNumDataItems); nData++) {
char szHex [4];
sprintf (szHex, "%0X", data[nData]);
strcat (szOutput, szHex};
}
Did we just do your homework for you?
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I have an application that working with files named like <name>.ext (ext is my extension)
I can run it this way: myapp.exe <file.ext>
But when I try to open this file from HTML page (<a href="a.ext">file</a> ) IE asks me about open or save. How can I have it to stop do this?
I've registered my MIME-type in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Accepted Documents
but it have no effect.
With the best regards, Vitaly.
|
|
|
|