|
Petzold introduced a technique for achieving true WYSIWYG printing way back in the late '80s. I used it in about 1993 with good results. Unfortunantly, I no longer have that code, or the book. The technique was called 'logical twips' and involved a formuila for adjusting the mapping mode to work for both the screen and the printer device context.
The "Logical Twips" Mapping Mode [^]
When I discussed mapping modes in Chapter 11, you might have thought the
MM_TWIPS mapping mode would be used by programs that make heavy use of
formatted text. In this mapping mode, logical units are in terms of 1/20
point. However, you probably won't want to use MM_TWIPS for the video
display, because the mapping mode is based on real inches rather than
logical inches. As a result, your program won't be able to equate the
correct point sizes (8, 10, 12, 14, 18, and 24) of the available screen
fonts to their heights in MM_TWIPS units.
You'll be better off if you define your mapping mode based on the
logical-pixels-per-inch dimensions available from GetDeviceCaps. I call this
the "Logical Twips" mapping mode; here's all you need to set it:
SetMapMode (hdc, MM_ANISOTROPIC) ;
SetWindowExt (hdc, 1440, 1440) ;
SetViewportExt (hdc, GetDeviceCaps (hdc, LOGPIXELSX),
GetDeviceCaps (hdc, LOGPIXELSY)) ;
Because the pixels-per-logical-inch values are always divisors of 1440, the
scaling factor for this mapping mode is an integer. With this mapping mode
set, if you want to request a font with 12-point line spacing (as we'll do
shortly), you can specify the height of the font as 240 (12 times 20)
logical units.
If you select a font into your device context and call GetTextMetrics to
obtain the dimensions of the font, you can calculate the type size in points
by using the formula:
(tm.tmHeight - tm.tmInternalLeading) / 20
The line spacing in points is equal to:
tm.tmHeight / 20
For some smaller fonts on low-resolution devices, the size and spacing of
the type might actually involve a fraction of a point--for example, 8-point
type with 8.5-point line spacing. To round to the nearest integer point
size, you might instead want to use the formulas:
(tm.tmHeight - tm.tmInternalLeading + 10) / 20
and:
(tm.tmHeight + 10) / 20
We'll use the "Logical Twips" mapping mode in the JUSTIFY program toward the
end of this chapter.
Once again, remember that the discrepancy between logical inches and real
inches occurs only for the display. If you use the "Logical Twips" mapping
mode with a printer, you'll simply duplicate the MM_TWIPS mapping mode.
"You get that which you tolerate"
-- modified at 19:55 Thursday 9th February, 2006
|
|
|
|
|
I have a modeless dialog with some controls. How to disable this dialog with all controls?
Best regards,
Eugene Pustovoyt
ICQ UIN: 161325180
|
|
|
|
|
Do something like this:
BOOL b = EnumChildWindows( hWndDlg, EnumFunc, NULL );
BOOL CALLBACK EnumFunc( HWND hwnd, LPARAM lParam )
{
EnableWindow( hwnd, FALSE );
}
Andy
Human beings were not meant to sit in little cubicles staring at computer screens all day, filling out useless forms and listening to eight different bosses drone on about about mission statements. -- Peter Gibbons
|
|
|
|
|
Are you wanting to disable all of the controls on the dialog, or the dialog itself?
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
Try this:
HWND hwnd = ::GetTopWindow(this->GetSafeHwnd());
while (hwnd)
{
hwnd = ::GetNextWindow(hwnd, GW_HWNDNEXT);
::EnableWindow(hwnd, FALSE);
}
------- sig starts
"I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
If you want to disable the control on this dialog, the MFC-way of doing it would be creating a variable
bool ControlsEnabled;
and use OnCmdUI-Handler on each Control to do
pCmdUI->Enable( ControlsEnabled /*&& other conditions*/);
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
Why do multithreaded programs behave differently in DEBUG mode and RELEASE mode?
|
|
|
|
|
Because you use two different libs or dlls. The debug versions contain more information to make it easier to debug the code, and probably also the behaviour is different so that a thread is halted when you debugstep into another one.
~RaGE();
|
|
|
|
|
Does that mean that a program running well in DEBUG mode may not run the same way in RELEASE mode?
|
|
|
|
|
|
hey guys
i'm a novice c++ programmer and i'm currently making a program
everything works fine, but there's one slight problem...
i need to have the program output a text on-screen and i don't know how.
Let me explain, the program i want to make basically displays a text on the screen of your computer.
not the DOS prompt where it executes the program, but the screen itself.
Think of an alert-messenger that does so not by using those windows, but by just displaying the text
it needs to display.
How can I do that?
If it's no trouble, i'm also wondering if the gotoxy(x,y) (using the conio.h file) works with whatever solution to my problem you have. And how can i make that text disappear after a pre-set amount of time?
thanks for your help
regards,
peter
#include borland c++ compiler 5.5
using Windows XP;
int main()
{
cout << "Hi! I'm Peter!\n";
return 0;
}
|
|
|
|
|
Peter Charlesworth wrote: Think of an alert-messenger that does so not by using those windows, but by just displaying the text
it needs to display.
I have no idea how to do it without "those windows", but you could draw your text on a transparent window, giving the impression that the text is displayed "on the screen".
~RaGE();
|
|
|
|
|
I am using the code below
typedef CArray<float, float> INT_PERCENT1;
INT_PERCENT1 arrPercentage1;
INT_PERCENT1 arrPercent1;
arrPercentage1 have a data in the array already added. but arrPercent have not element yet added. I want to copy a data from
arrPercentage1 to arrPercent1
for ( int j = 0 ; j< countloop ; j++)
{
arrPercent1.SetAt(j, m_arrPercentage1.GetAt(j));
m_arrRank1.SetAt( j , 0);
}
at the line arrPercent1.SetAt(j, m_arrPercentage1.GetAt(j));
the program crashes , while debugging i got the error
CXX0030: Error: expression cannot be evaluated
Regards.
|
|
|
|
|
zahid_ash wrote: I want to copy a data from
arrPercentage1 to arrPercent1
So why not just use the Copy() method?
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
It crashes because you do not assign memory to your second table.
Three possibilities:
for ( int j = 0 ; j< countloop ; j++)
{
arrPercent1.SetAtGrow(j, m_arrPercentage1.GetAt(j));
m_arrRank1.SetAt( j , 0);
}
or initialize the size before the loop:
arrPercent1.SetSize(m_arrPercentage1.GetSize());
for ...
Or, the best solution:
arrPercent1.Copy(m_arrPercentage1);
~RaGE();
|
|
|
|
|
Hi all,
I am new to VC++.I have developed an "exe" application in VC++.I need to execute some DOS
commands from this application but, the problem is whenever I run the code, it automatically creates a dos window because of the "system" command and covers my dialog window. Is there any funtion that can hide or minimize that DOS window?If so where do i place that part of the code??
Thanks
Sasha
|
|
|
|
|
Can you post the code you use to "execute some DOS commands" ?
If you use WinExec to fire up the commands, you can provide SW_HIDE as second parameter to hide the window. More elaborated would be to use the CreateProcess function.
Is your app a MFC app or a console app ?
~RaGE();
|
|
|
|
|
sashabkvs wrote: ...because of the "system" command...
Which is a very good reason to avoid using this antiquated function. It's just a holdover from the Unix environment. What exactly is it that you are trying to do?
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
Hello!
I want to catch events on the usb, like "the user plugged in a hid"
I tried the WM_DEVICECHANGE, but this one helps only with USB-Sticks.
Is there a way to get this information?
Thank You
|
|
|
|
|
Set the GUID ( DEV_BROADCAST_DEVICEINTERFACE.dbcc_classguid ) to the class of devices that you want to monitor. That will take some digging on your part to discover the proper GUIDs
DEV_BROADCAST_DEVICEINTERFACE devBroadcastDeviceInterface;
ZeroMemory( &devBroadcastDeviceInterface, sizeof( devBroadcastDeviceInterface ));
devBroadcastDeviceInterface.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE);
devBroadcastDeviceInterface.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
devBroadcastDeviceInterface.dbcc_classguid = GUID_DEVINTERFACE_USB_DEVICE;//GUID_DEVINTERFACE_HID
m_hDevNotify = RegisterDeviceNotification ( g_hWnd, &devBroadcastDeviceInterface, DEVICE_NOTIFY_WINDOW_HANDLE );
|
|
|
|
|
Good answer for the use case. I used
static /*const*/ GUID GUID_DEVINTERFACE_USB_DEVICE =
{ 0xA5DCBF10L, 0x6530, 0x11D2, { 0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED } };
However if I wanted to detect a user inserting/removing a card from a usb card reader... any one? Currently i only know if the carder reader is plugged/unplugged... not if the card is inserted / removed
|
|
|
|
|
Hi all
i'm trying to retrieve primary keys by calling SQLPrimaryKeys function, but the problem is that Ms. Access doesn't support this function, Does anyone know how get the primary keys of a specific table for MS. Access using ODBC.
|
|
|
|
|
Use a CDaoTableDef object and its GetIndexInfo() method.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
I am using
typedef CArray<float, float=""> INT_PRICE2;
and using its object like
INT_PRICE2 m_arrPrice2;
I want the m_arrPrice2 be a two dimensional array.
How it can be?
and how to add , get and play with its elements?
Thanks.
Regards.
|
|
|
|
|
zahid_ash wrote: I want the m_arrPrice2 be a two dimensional array.
i'd go into int m_arrPrice2[][]; instead of using your CArray typedef which is not clear at all about what it is...
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]
|
|
|
|