|
hi, you need a to use a standard unit to define the size of ua graphic other than using pixels e.g inches, coz if you use pixels , each printer will come with different aspect ratios of the pixel units, and you cud have a printer whose one inch long on paper , is say 100 pixels while on the screen of your computer it could have been 150 pixels making an inch of your image so you end up having a different image on paper .
this is what i advise you to do. and i give an example of making some cells and they'll print same way thy appear on screean
define 2 variables in the header file of your view call them,
int m_nCellWidth and m_nCellHeight;
Inside the Draw function of your view
put this code.
m_nCellWidth = pDC->GetDeviceCaps(LOGPIXELSX);
m_nCellHeight = pDC->GetDeviceCaps(LOGPIXELSY)/4;
what does this function do before assingning some values in your integers.
the Function GetDeviceCaps(PARAMS) is a member of pDC (screen or printer) and it returns (depending on parameters) the number of pixels of the Devise context that make up one inch of y-axis (if PARAMS are LOGPIXELSY) or x - axis (if PARAMS are LOGPIXELSX);
now you have a unit that is equivalent to a quarter of an inch on y axis (vertical axis) of any printer m_nCellHeight and another m_nCellWidth representing a an inch on x-axis.
it's not a must you divide by 4, to make a quarter inch unit for y-axis, you can still use a full inch, it's olnly that the example i want to give you requires a quarter of an inch unit.
now put this code.
//////////////////////////////////////
int nMyPageHeight = (20 * m_nCellHeight ); // about 20 cells
int nMyPageWidth = (5* m_nCellWidth); // about 5 columns
for (int i=0; i <nmypageheight i="" mode="hold">{
// draw horizantal lines from left to right
pDC->MoveTo(0,i * m_nCellHeight);
pDC->LineTo(nMyPageWidth ,i * m_nCellHeight);
}
for (int j=0; j <nmypagewidth j="" mode="hold">{
// draw vertical lines top of page to bottom
pDC->MoveTo(j *m_nCellWidth ,0);
pDC->LineTo(j *m_nCellWidth ,nMyPageHeight);
}
////////////////////////////////////////////////////
now try to print your image and see what happens.
note that the print function calls the OnDraw() function of the view class and passes pDC, pointer to the printer, so if you call this code in another function other than the draw, make sure you call the Function from the OnDraw() function and pass pDC to it, dont use CClientDC(),
|
|
|
|
|
I think if generate a graphic according to the paper size for printing,
the graphic will not be scaled.
I wrote as below. I'm not sure whether it works (no printer on hand). And it seems lack of a print pool, doesn't it? When it's printing, how to make it like MS Word?
void CFigDlg::OnBnClickedBtnPrint()
{
using namespace Gdiplus;
CPrintDialog dlg(TRUE,
PD_RETURNDC|PD_ALLPAGES|PD_USEDEVMODECOPIES|PD_NOPAGENUMS|PD_HIDEPRINTTOFILE|PD_NOSELECTION,
this);
if (dlg.DoModal()==IDOK) {
DEVMODE *pDM=dlg.GetDevMode();
HDC hDC=dlg.GetPrinterDC();
CDC dc;
dc.Attach(hDC);
int dpi_x=dc.GetDeviceCaps(LOGPIXELSX);
int dpi_y=dc.GetDeviceCaps(LOGPIXELSY);
Size size;
size.Width=INT(pDM->dmPaperWidth*dpi_x/2.54f);
size.Height=INT(pDM->dmPaperLength*dpi_y/2.54f);
if (bool(m_pFig)) {
Bitmap *pBm=m_pFig->GenBitmap(size);
Graphics g(hDC);
g.DrawImage(pBm,0,0);
delete pBm;
}
}
}
system
|
|
|
|
|
Hi
I have done a project in VC++ 6.0 and now I want to upgrade few parts in the code so I have to increase the array size and variable type in the code If I change the array size also it is not reflecting in the code As soon as I place Mouse pointer on the variable name in the code.
Please help its urgent.
Regards
Murali
|
|
|
|
|
Murali_mom wrote: Please help its urgent.
Yes sir, right away...
Murali_mom wrote: If I change the array size also it is not reflecting in the code As soon as I place Mouse pointer on the variable name
DEBUGGING[^]
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
VC6 (maybe VB6 too...) was terrible about losing track of information about your code.
Close it down, and use Task Manager to make sure the process goes away too. Then delete the ncb file for that workspace, and run VC6 again.
It will regenerate the classes on the left pane, and hopefully also the same information is used for mousing over things.
Iain.
|
|
|
|
|
Thanks for your answer it worked
|
|
|
|
|
LPDEVMODE CPrintDialog::GetDevMode() const
{
if (m_pd.hDevMode == NULL)
return NULL;
return (LPDEVMODE)::GlobalLock(m_pd.hDevMode);
}
I search in dlgprnt.cpp, no ::GlobalUnlock(m_pd.hDevMode) .
system
|
|
|
|
|
MSDN:For movable memory objects, GlobalLock increments the count by one, and the GlobalUnlock function decrements the count by one. For each call that a process makes to GlobalLock for an object, it must eventually call GlobalUnlock.
Did you check that you link to kernel32.lib and have windows.h included?
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
If I need to free the resource, I have to call ::GlobalUnlock(m_pd.hDevMode) .
I seems not so good.
And I tried not to free it, no memory leak.
I don't know which way is ok.
system
|
|
|
|
|
HI,everyone.
I have used the stream I/0 to write myOwn.exe file in the source.exe file.When the combined file is executed,it can read myOwn.exe out and create two processes to execute them(This procedure is achieved in myOwn.exe).But I think this method is a little stupid.
Do you have any other great idea to combine them to a single,in which the two .exe files can be executed by turns?
modified on Wednesday, September 17, 2008 9:57 PM
|
|
|
|
|
|
thanks a lot ,a good article.
You know some birds are not meant to be caged, their feathers are just too bright.
|
|
|
|
|
Occassionally my project crashes and displays a dialog box that says, "Unhandled Exception in mt.exe". What might be the cause of this problem?
This problem occurs not only in my current working project but in other VC++ projects also(when I tried to open those projects, I was unable to open those projects and I got a statement like, "Memory location could not be read"). When I restart my system things become normal. But the problem reoccurs suddenly. How to resolve this error?
|
|
|
|
|
The Mt.exe file is a tool that generates signed files and catalogs. It is available in the Microsoft Windows Software Development Kit (SDK)
T.RATHA KRISHNAN wrote: Occassionally my project crashes and displays a dialog box that says, "Unhandled Exception in mt.exe". What might be the cause of this problem?
May be something is triggering the crash. don't exactly know what
T.RATHA KRISHNAN wrote: his problem occurs not only in my current working project but in other VC++ projects also
may be your VS installation has gone corrupt. Try reinstalling it
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
1) Is there some way I can get a list of IDC_ control ids dynamically at run time to step through in a loop like the following
List idList = SomeFunction() // Get a list of control objects
for(int k = 0; k < idList.length(); k++)
{
GetDlgItem(k.id)->EnableWindow(false);
}
2) The other option I though of is that if all my IDC_ ids increment, I would only need to know the total number of items and I could do the following:
unsigned int cnt = SomeFunction(); // Get the total number of control objects
for(int k = 0; k < cnt; k++)
{
GetDlgItem(k)->EnableWindow(false);
}
thanks
|
|
|
|
|
Using EnumChildWindows or GetWindow() you can get all the child windows handle. Then you can call ::EnableWindow() with that handles.
|
|
|
|
|
Hi All
I have problem to copy File/Folder data.I have source and destination path name and i want to copySource file to destination file.I am useing these code..
CopyFileA("C:\\a.txt","D:\\a.txt",TRUE);
Plz help me
|
|
|
|
|
Please use GetLastError()[^] and find out what went wrong.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Thx's i found exception
a.exe: 0xC00000FD: Stack overflow.
Following exception occurred: -1073741571 -- File: e:a\delayeddirectorychangehandler.cpp Line: 229
And line is here..
TRACE(_T("Following exception occurred: %d -- File: %s Line: %d\n"), dwEx, _T(__FILE__), __LINE__);
I am useing directorywatcher and take example from codeproject.Lunk is here http://www.codeproject.com/KB/files/directorychangewatcher.aspx[^]
plz help me
|
|
|
|
|
Please follow Rajesh's advice and use GetLastError().
|
|
|
|
|
knowvc wrote: I have problem
Which is ? How can we help you if you don't provide enough information ?
Did you check that "a.txt" doesn't exist (you are passing TRUE for the bFailIfExists parameter) ?
knowvc wrote: CopyFileA
Why are you using the version specific to non-UNICODE builds ? You should use CopyFile instead.
|
|
|
|
|
Hello everyone,
When in the ATL wizard to create a coclass, we specify ProgID under COM category.
My questions,
1. I think the progid could be used by COM consumer/client to create COM object instance without using GUID/CoClass name, and just use progid. And progid is for each coclass level, not for interface or for COM server level. is that correct?
2. I am taking quite some time in MSDN and Google to find a simple sample of how to use progid to create coclass object. Could anyone refer some sample pleases?
3. Besides using progid to create a coclass, any other usages?
thanks in advance,
George
|
|
|
|
|
|
Thanks Sohail,
You have made a so great reply! Very comprehensive!
Two more questions,
1.
Normally how will COM comsumer know progid? From typelib file, IDL file or from some other means?
2.
Each progid is for each coclass type (e.g. suppose in my in-process server DLL, I defined 5 coclas types, then I should have 5 progids?), and progid is not for interface or in-process server DLL, correct?
regards,
George
|
|
|
|
|
1. Normally some information will be required by consumer of your COM server. So ProgId, ClassId, Interface descriptions etc need to be published. There are various ways for the consumer to instantiate and consume the services provided by the COM Server (one of which is using ProgId). If information from TypeLib is to be queried then you may use Type Description Interfaces and Functions[^]. There is also IProvideClassInfo[^] interface that helps accessing the type information for an object's coclass.
ProgId could be published in TypeLib files, Interface and coclass declaration (header) files or simply as part of your COM server documentation.
2. Yes. As mentioned by Larry Osterman in his blog entry (see the link I posted earlier) - "The PROGID provides the ability to define a string alias for a particular COM object. Thus with the PROGID, you can access a COM object without having to know it's CLSID. This can be quite handy, especially when you're working in languages that don't provide easy access to a GUID data type. A PROGID is simply a string representation of the class. "
Glad I could help.
PS: What registry entries are needed to register a COM object[^] is a good read.
Sohail
modified 21-Apr-21 21:01pm.
|
|
|
|