|
In addition to CPallini's reply...
Note that many devices don't provide an accurate value when you call
GetDeviceCaps(LOGPIXELSn) - some displays aren't capable of it, some can
be stretched horizontally and vertically, etc..
If you need accuracy, you may need to provide some method of calibration.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Now we can use the ID2D1Factory interface to get the desktop DPI directly as shown below.
ID2D1Factory* m_pDirect2dFactory;
D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &m_pDirect2dFactory);
FLOAT dpiX, dpiY;
m_pDirect2dFactory->GetDesktopDpi( &dpiX, &dpiY );
with regards,
Manoj G.R.
- "So far so good, but the best is yet to come."
|
|
|
|
|
Hi ALL,
I am doing project in VC++ 6.0, When I run the application, application gets crash. Message box is display with 3 button as "Don't Send" ,"Ignore" and "send". I check all values in my function if there is any NULL value.In my code there is no NULL value is occured any object. Please send me solution to this problem if anybody have. Tell me the possibilities of application crash.
Thanks in Advance
hi
|
|
|
|
|
Have you tried debugging the program? Build, Start Debug, Go (or hit F5). Make sure you compile in debug mode (Build, Set Active Configuration to Win32 Debug). This should stop on the line of code that's causing the problem.
Otherwise, post some code.
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Hi Steve,
I write code in CPageView class which is derived from CView class. My project is to create web page design tool. when I create page by using my code, as the page is open there is error ocuure. I write customize function to open web page. The error is occur after page is open and application gets crash with messgeBox having 3 buttons as Send Error,Don't sent error and ignore.
void CPageView::OpenWebSite(int nTabIndex)
{
if(nTabIndex > 0 && nTabIndex < nSize+1)
{
CString strPagePath = pFrame->m_selWebPagePaths.GetAt(nTabIndex-1);
theApp.OpenDocumentFile(strPagePath);
}
}
Thanks
Abm
|
|
|
|
|
Potential problems I see:
1. pFrame is null
2. (nTabIndex - 1) is out of range of the array
3. nSize is not the actual size of the array being indexed
You're probably trying to access an element of m_selWebPagePaths that doesn't exist.
Put a breakpoint in there and check the value of nTabIndex and nSize. Make sure nSize is the same as m_selWebPagePaths.Count (or GetSize).
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Hi Steve,
I check above all values by adding break point. There is no NULL value so OpenDocument() function called sucessfully and document is open. but after opening the document the application get crash. that is the main problem here. please give me some hint if know !!!
Thanks in Advance
abm
|
|
|
|
|
When you run the application is in debug mode, the IDE gives valuable info (see for instance call stack window) about the error occurred.
Try to detect the exactly the troublesome point and post the relevant code.
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.
[my articles]
|
|
|
|
|
In iostream library, <xstring> is the internal header file of <string>. But there is not #include <xstring> in file <string>. How do they build up the relationship??
Maxwell Chen
|
|
|
|
|
Maxwell Chen wrote: In iostream library, <xstring> is the internal header file of <string>
How the above comes out (i.e I never heard before, please explain)?
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.
[my articles]
|
|
|
|
|
CPallini wrote: How the above comes out (i.e I never heard before, please explain)?
#include <string>
std::string str;
By right-clicking std::string and choosing [Go to definition], VC++2005 leads you to file <string>. And then by right-clicking basic_string and [Go to definition], you are lead to file <xstring>. In the beginning of <xstring>, it states that it is the internal header file of <string>.
(I am at home and do not have VC++ 2005 now. But it is something the like.)
Maxwell Chen
|
|
|
|
|
The target of my request was the <xstring> :
you said
Maxwell Chen wrote: <xstring> is the internal header file of <string>
but I never heard about <xstring> . How can you affirm that?
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.
[my articles]
|
|
|
|
|
I updated my previous reply.
Maxwell Chen
|
|
|
|
|
as far I can understand, there is a long nesting of includes, starting from <string> that includes <istream> , that includes <ostream> , that includes <ios> , ..., terminating with <stdexcept> that includes <xstring> .
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.
[my articles]
|
|
|
|
|
I'm not sure, but I remember that <string> only includes <xmemory> ...
I do not have VC++2005 at home now. Let me check next week.
Maxwell Chen
|
|
|
|
|
CPallini wrote: starting from <string> that includes <istream>, that includes <ostream>, that includes <ios>, ..., terminating with <stdexcept> that includes <xstring>.
Got it! Thanks!
Maxwell Chen
|
|
|
|
|
(Update: Problem solved)
I'm trying to use CDC::GetWindow to get a pointer to a CWnd object to perform some tests but CDC::GetWindow() returns NULL. I'm trying to derive the CDC from the Graphics object passed into a function as follows...
void SomeFunction(Graphics& graphics)
{
HDC hDC=graphics.GetHDC();
CDC* pDC=CDC::FromHandle(hDC);
if (pDC) {
CWnd* pWnd=pDC->GetWindow();
if (pWnd) {
}
}
graphics.ReleaseHDC(hDC);
}
Can anyone tell me the folly of my ways?
thanks in advance
modified on Friday, December 28, 2007 11:17:40 AM
|
|
|
|
|
Why are you doing that (i.e. have you no control on Graphics object instance?)?
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.
[my articles]
|
|
|
|
|
I'm passing the graphics object around to drawing functions in classes that have no knowledge of who is using them. Those other classes, however, are interested in knowing whether the window the Graphics object is drawing to has the input focus so they can perform their drawing actions differently.
I'm just trying to minimize the number of parameters I'm passing around.
|
|
|
|
|
Well, I don't think that a Graphics object is a good transport medium for a CWnd one. Pass needed parameters packed in a struct.
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.
[my articles]
|
|
|
|
|
I realized what I was doing wrong.
I'm using a memDC so there is no window associated with the underlying DC.
Thanks for the response.
I apologize for my oversight.
|
|
|
|
|
Since the graphics object has the HDC, and the HDC knows which HWND it is associated with (if any) it seems reasonable to say the overhead of digging the HDC out and creating a struct and setting it up are approximately even.
Granted, I screwed it up but the concept seems sound if one can assert the HDC is associated with a window and not just a memory buffer.
Anyway, thanks for your advice as many opinions usually lead to a solution directly or indirectly.
|
|
|
|
|
I'm happy you've found a solution.
BTW a device context maybe associated to the whole screen, so you can get no window anyway (you can state as a precondition that screen DCs are banned!)
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.
[my articles]
|
|
|
|
|
Do you want to get handle to a control?
|
|
|
|
|
No, I'm just trying to get a generic window handle for the window the Graphics object drawing commands will effect.
I'm trying to minimize the number of parameters to each function and since the Graphics object is being passed in, I was hoping to use the associated DC to track down the window.
|
|
|
|