|
The GetClientRect(...) method always returns the size of the client area on the screen, even when printing. You need to use something like the CPrintInfo::m_rectDraw when drawing to the printer. You can save the print rect in CView::OnBeginPrinting(...) and use the pDC->IsPrinting() to flag using the printer rect vs. the client rect.
This opens up a whole can of worms when trying to use your dynamic screen drawing code to draw to the more static printer page. There are other ways to get the printer page information. Search the MSDN for "get default print info" and see what you get. Of course this all opens a bigger can of worms.
You may want to just try using CPrintInfo::m_rectDraw first. It may be all you need.
Good Luck
Jonathan Craig
www.mcw-tech.com
|
|
|
|
|
Hi !
I wrote system hook for right mouse click i.e. using WH_MOUSE in SetWindowHookEx()
Now for the hook procedure in the .dll file I added the code..
//=====================================================
EXPORT LRESULT CALLBACK MouseProc(int nCode,WPARAM wParam,LPARAM lParam)
{
switch(wParam)
{
case WM_RBUTTONUP:
{
DisplayDialog();
return CallNextHookEx(hK,nCode,wParam,lParam);
}
default:
return CallNextHookEx(hK,nCode,wParam,lParam);
}
}
//======================================================
// The above code should display a Modless Dialog Box on screen .. when it intercepts a Right mouse click.
The problem I am facing here is that though the dialog box does pop up...instead of one ... they are multiple in number and keep on increasing !!!
I traced the whole execution and found that the hook procedure was receiving multiple WM_RBUTTONUP messages when I just right clicked once.
Why is this happening ?
Another thing.. What do I do if I wanted to check if the
Shift key was pressed when right click was made.
Do I have to install a Keyboard hook for this, or can I get the info from wParam itself.
Please Help
DB
Note:
1. DisplayDialog() function displays a dialog box on screen.
2. Variable hk stores the hook handle from SetWindowsHookEx function.
|
|
|
|
|
Is it possible to use RDS.Dataspace from Visual C++ to call a remote server with the http protocol. I can do this from VB, but I can't make it work from VC++.
Any comments ?
|
|
|
|
|
I am using WebBrowser control in VC++ project.
WebBrowser loads page form Intranet Server. I don't want to show message like "The page cannot be displayed" in case server is down. I want to show some local html page which will be stored on client computer.
Does anyone know how to catch event when page is not successfully loaded from server?
Thanks
Sanjeev.
|
|
|
|
|
You could try first testing the existence of the page programatically (just send a HEAD request - don't download the page). If the test succeeds, ask the web browser control to load the page. Otherwise, direct the control to a local 404 page.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
HANDLE SAHeap = HeapCreate( HEAP_GENERATE_EXCEPTIONS , 0 ,0 );
PSECURITY_ATTRIBUTES pSD = NULL;
ACL_SIZE_INFORMATION ASizeInfo;
DWORD LenNeeded , iAce;
BOOL DaclF , AclDefF;
BYTE DAcl [256];
BYTE AType;
PACCESS_ALLOWED_ACE pAce;
PACL pAcl = (PACL) &DAcl;
POSITION pos = filelist->GetHeadPosition();
for(short i = 0 ; i < filelist->GetCount() ; i++ )
{
GetFileSecurity( (LPCTSTR)filelist->GetNext(pos).GetString() , OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION
| DACL_SECURITY_INFORMATION , pSD , 0 , &LenNeeded );
pSD = (PSECURITY_ATTRIBUTES)HeapAlloc(SAHeap , HEAP_GENERATE_EXCEPTIONS , LenNeeded);
GetFileSecurity( (LPCTSTR)filelist->GetNext(pos).GetString() , OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION
| DACL_SECURITY_INFORMATION , pSD , LenNeeded , &LenNeeded );
GetSecurityDescriptorDacl(pSD , &DaclF , &pAcl , &AclDefF);
GetAclInformation(pAcl , &ASizeInfo , sizeof(ACL_SIZE_INFORMATION) , AclSizeInformation);
for(iAce = 0 ; iAce < ASizeInfo.AceCount ; iAce++)
{
AType = GetAce(pAcl , iAce , (LPVOID*)&pAce);
if(AType == ACCESS_ALLOWED_ACE_TYPE)
AfxMessageBox("Access");
}
}
The second time when first "for" loop run unhandled error happend after this line:
GetFileSecurity( (LPCTSTR)filelist->GetNext(pos).GetString() , OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION
| DACL_SECURITY_INFORMATION , pSD , 0 , &LenNeeded );
and thats access violation...error.
Any idea?
Mazy
"The more I search, the more my need
For you,
The more I bless, the more I bleed
For you."The Outlaw Torn-Metallica
|
|
|
|
|
If fileList has n positions, seems to me you're trying to obtain n+1 elements: one GetHeadPosition and n GetNext s. If the list has two elements, you'll run into an error at the second iteration.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
It seems that you are right.Now how can I deal with fileLlist ?
Mazy
"The more I search, the more my need
For you,
The more I bless, the more I bleed
For you."The Outlaw Torn-Metallica
|
|
|
|
|
Oop,s I wasn't right, the problem is different: you're calling GetNext twice in each iteration. Do it only once, and use this reference value later:
for(...)
{
TYPE_OF_ELEMENTS_OF_FILELIST& element=filelist->GetNext(pos);
...
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Yes,I was thinking whats wrong with my CSdtringList ,I've used it many times before like this but why it does not work here.Thanks Joaquín,like always.
Mazy
"The more I search, the more my need
For you,
The more I bless, the more I bleed
For you."The Outlaw Torn-Metallica
|
|
|
|
|
Are you sure GetNext() returns you a value?
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
Need Web-based database administrator? You already have it!
|
|
|
|
|
Philip Patrick wrote:
Are you sure GetNext() returns you a value?
Yes,the problem is here,but I don't know the solution?
Mazy
"The more I search, the more my need
For you,
The more I bless, the more I bleed
For you."The Outlaw Torn-Metallica
|
|
|
|
|
It doesn't have any comments
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
Is there a way that I can read the version info in the resource and display it in the about box?
Thanks
Thomas
modified 29-Aug-18 21:01pm.
|
|
|
|
|
Hi,
Have a look at
GetFileVersionInfoSize
GetFileVersionInfo
Regards,
Prem
|
|
|
|
|
Hi all, long time no see. I have a smallish problem that I just can't get my head round. I have installed Microsofts DirectX 7 SDK and want to start using it. I have updated the lib and include directories so they look in the appropriate places (i.e. where i installed the sdk). However, when I try to use DirectDrawCreateEx() with parameter 3 as IID_IDirectDraw7 I get two unresolved externals for the function and GUID. I've had a look at the include directory of the SDK, only header files? is that normal. Is it trying to access a lib and is failing for some reason??? why? why? why? Could someone please help or point me to a page that would help me.
Much appreciated,
Alan.
"When I left you I was but the learner, now I am the master" - Darth Vader
|
|
|
|
|
Hi all, I found the problem. For anyone who has a similar problem for unresolved externals do this:
1. Make sure you have the relevant lib and include directories (where you installed SDK) listed in Tools > Options > Directories menu (and are at top).
2. Go to Project > Settings > LINK > Object/Library Modules and add ddraw.lib and dxguid.lib. (btw. Microsoft recommends you do it this way as opposed to #include headers, honest it says on their web site in the DirectX SDK section).
You'll find the errors will magically disappear if you've done it correctly.
Alan.
"When I left you I was but the learner, now I am the master" - Darth Vader
|
|
|
|
|
Me again,
Can is Automate Outlook / Outlook Express in a way that I prepare a New Message, where:
* Receiver Address
* Message Body
* Attached file(s)
is already included?
Would be nice if I can do this for Netscape etc. as well.
The earth is not dying. It is being killed.
|
|
|
|
|
You can use MAPI. If you call MAPISendMail() with the MAPI_DIALOG flag set, it will display the message, ready to be sent in Outlook/Outlook Express/Whatever. I have no idea if it works for Netscape though.
---Shog9---
From now on we can call C# and MC++ "The square wheel languages" -- Jack Handy, The Lounge
|
|
|
|
|
Hi,
I'm looking for a C++ .lib (or sources) that can create an archive of multiple files - preferedly something that can be unpacked with winzip again.
It should be free, royalty-free, and no-strings-attached. good compression ratio is not that much an issue, but would be nice.
Data is a few text and binary files in a single folder (no subdirs (as of now)), from a few hundred bytes to usually < 2MB.
Is there anything like this?
The earth is not dying. It is being killed.
|
|
|
|
|
|
InfoZip should do what you want. It's (obviously) based on zlib.
|
|
|
|
|
Crypto++ includes Gzip and Zlib support as well as a bunch of great Crypto stuff. Highly recomended.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
I am trying to write a function for a CFormView called BatchPrintPage2().. the first part of this function is trying to get a handle on HDC. This is before I try to get the hDC:
DOCINFO di ;
CPrintInfo printInfo ;
CMyDoc *pDoc = (CMyDoc*)GetDocument() ;
CString filename ;
CDC dc ;
CRect draw_area ;
ASSERT_VALID(pDoc) ;
filename = pDoc->GetPathName() ; // make sure the compares will match
filename.MakeLower() ;
CPrintDialog dlg(FALSE) ;
at this point i try to get the hDC, the first way i was told to try was:
HDC hDC = dlg.CreatePrinterDC() ;
but this always returns null.
the other way i have tried is:
dlg.GetDefaults();
HDC hDC = dlg.m_pd.hDC;
this actually seems to work.. but then i get to the rest of the function..
di.cbSize = sizeof(DOCINFO) ;
di.lpszDocName = pDoc->GetPathName() ;
di.lpszOutput = filename ; // prepare the print information structure
dc.Attach(hDC) ;
printInfo.m_bDirect = TRUE ;
printInfo.m_rectDraw.left = 0 ;
printInfo.m_rectDraw.right = dc.GetDeviceCaps(HORZRES) ;
printInfo.m_rectDraw.top = 0 ;
printInfo.m_rectDraw.bottom = dc.GetDeviceCaps(VERTRES) ;
draw_area = printInfo.m_rectDraw ;
dc.StartDoc(&di) ;
OnPreparePrinting(&printInfo) ; // start printing the document
for (printInfo.m_nCurPage = 1 ; printInfo.m_nCurPage <= printInfo.GetMaxPage() ; printInfo.m_nCurPage++)
{
dc.StartPage() ;
OnPrint(&dc, &printInfo) ;
dc.EndPage() ; // reset page size as OnPrint may have modified them when header / footers were added to the page
printInfo.m_rectDraw = draw_area ;
}
OnEndPrinting(&dc, &printInfo) ;
dc.EndDoc() ;
VERIFY(dc.DeleteDC()) ;
this doesn't give any errors, but nothing prints. When tracing i see that OnDraw is called, but IsPrinting() is false. I have tried setting dc.m_bPrinting = TRUE, and this makes onDraw get called with IsPrinting() true, but it still prints nothing. My printer queue actually shows the job being sent to the printer, but when i captured the screen and look at it the 'Pages' and 'Size' columns are both blank..
also a major problem is that the 'for' loop listed above corrupts the hell out of my document.. my document file just gets destroyed with garbage from this for loop.. the dc.StartPage() sets the file to the following: (does this look like its printing to the document file somehow?)
%-12345X@PJL ENTER LANGUAGE=PCL600
*t600R&u600D*r3F&l0O&l1H&l2a8c1E*p0x0Y&l1X*b0M
*v0o0TE%-12345X
any help is much appreciated.. i can almost smell printing a bunch of views without a dialog
thanks!
-dz
|
|
|
|
|
Further to my reply in your other thread.
Looking at the code, if your getting a valid DC then I would expect this to work. The first things to check are that you are setting the number of pages you want to print in the views OnPreparePrinting function. For testing I would by default set this to 1.
pInfo->SetMaxPage(1) ;
You will then know exactly how many times the loop will run for. The next thing is to check for the document corruption that is happening. Put a breakpoint at the start of the for loop, and try stepping over the function in it while viewing the pDoc object in the variables/watch window. If you see any of them change (turn red), then you will see in what procedure the corruption of your doc object is happening. I would most probably think that its the CView::OnPrint() or CView::OnDraw() procedures at fault. As this code you are using is a derivative of code I used for printing documents to a PDF file (where I get a DC for a PDF printer driver), I would expect all that to work without problems.
I just noticed that there is a call to CView::OnBeginPrinting() missing just before the for loop, this is probably what will set the m_bPrinting falg for OnDraw to work correctly. It may also do some other miscellaneous stuff to avoid the corruption that is happening.
If you have further problems, post some updated code and we can go from there. It may also help to post the OnDraw() code of your view.
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
|