|
Goodness. It's supposed to grab the screen then print only the bits of it that contain the dialog.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Will that print the frame though ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
It should, if you pass in PRF_NONCLIENT . I've not tried it though...
Shog9
------
The Army's on Ecstasy, so they say -
I read all about it in USA Today.
They stepped up urine testing to make it go away,
'cause it's hard to kill the enemy on ol' MDMA...- Oysterhead
|
|
|
|
|
If you want to draw the entire dialog, I suspect you'll need to capture the screen, then print the part of the resultant bitmap you need. Do you want to print the dialog itself, or only it's contents ? That is, do you want to print the little x to close the window, the frame and the dialog title ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
draw the entire dialog!
i can capture the screen and save in .BMP. but the bit map has no palette. how can i print it!
|
|
|
|
|
Great - don't save it, just get the co-ordinates of the window and print only that part of it.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
thank u.
can u help me check out my code,please?
CDC *pDC=GetWindowDC();
CBitmap bm;CRect rc;GetWindowRect(rc);
int Width=rc.Width();//GetSystemMetrics(SM_CXSCREEN);
int Height=rc.Height();//GetSystemMetrics(SM_CYSCREEN);
bm.CreateCompatibleBitmap(pDC,Width,Height);
CDC tdc;tdc.CreateCompatibleDC(pDC);
CBitmap*pOld=tdc.SelectObject(&bm);
tdc.BitBlt(0,0,Width,Height,pDC,0,0,SRCCOPY);
tdc.SelectObject(pOld);
BITMAP btm;
bm.GetBitmap(&btm);
//
//here. btm can be save as BMP file
dc.StartPage(); // begin new page
Info.m_nCurPage = page;
CDC MemDC;
MemDC.CreateCompatibleDC(&dc);
pOld=MemDC.SelectObject(&bm); ///
dc.BitBlt(rc.left,rc.top,rc.right-rc.left,rc.bottom-rc.top,&MemDC,0,0,SRCCOPY);
///but here .
//not be printed . the printer only print the bits,too.and the size of printer document is big!
//
|
|
|
|
|
This all looks right, I don't get what the problem is. What are the bounds of the bitmap ? Have you tried blting it to the screen ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
yes.
i have tested it.it can be bited to the screen.
my printer is canon lbp_800.
it's my printer's problem?
|
|
|
|
|
It's odd, because in theory if you send a 800x600 bitmap to a printer, you should expect to get a very small bitmap, because most printers have at least 600 dots per inch. IF the bitmap is fine, and the printer driver is hanging with a large amount of data passing through, then the problem is most certainly the print code.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
then,
how can i do?
save as BMP file,and print it with MS paint?
please
|
|
|
|
|
No, that would clearly be a hack. Print some text to your printer, then create a small bitmap programatically and print that. Build your way up until you work out where it is failing, and fix it ( naturally ask questions if you're confused or stuck, and provide whatever info you manage to find on the way ).
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
|
thanks a lot.
i have printed it.
this is my code
CDC memDC;
CWindowDC dc(this);
CRect rcrc;GetWindowRect(rcrc);
int bmpWidth = rcrc.Width();
int bmpHeight = rcrc.Height();
memDC.CreateCompatibleDC( &dc );
CBitmap * bitmap = new CBitmap();
bitmap->CreateCompatibleBitmap(&dc,bmpWidth, bmpHeight);
CBitmap * pOldBitmap = (CBitmap *) memDC.SelectObject(bitmap);
if (pOldBitmap == NULL) // if bitmap is very big, better check this !
{
memDC.DeleteDC();
delete bitmap;
AfxMessageBox("Not enough resource for the bitmap. Either reduce the bitmap dimension or \nswitch to lower screen setting (e.g. 256-color mode), and try again.");
return;
}
//draw bitmap here, or it can be done in another function
//
memDC.BitBlt(0,0,bmpWidth,bmpHeight,&dc,0,0,SRCCOPY);
// memDC.Ellipse(0, 0, bmpWidth - 1, bmpHeight - 1);
CDC prtDC;
CPrintInfo printInfo;
CSize size;
DOCINFO di;
CString szPortName, szAppName, szPrintError;
szAppName.LoadString(AFX_IDS_APP_TITLE);
szPrintError = "";
CSize paper_size; //printer paper size in mm
int xLogPPI = 0;
int yLogPPI = 0;
if( AfxGetApp()->GetPrinterDeviceDefaults(&printInfo.m_pPD->m_pd) )
{
HDC hDC = printInfo.m_pPD->m_pd.hDC;
if (hDC == NULL)
hDC = printInfo.m_pPD->CreatePrinterDC();
if(hDC !=NULL)
{
prtDC.Attach(hDC);
paper_size.cx = prtDC.GetDeviceCaps(HORZSIZE);
paper_size.cy = prtDC.GetDeviceCaps(VERTSIZE);
xLogPPI = prtDC.GetDeviceCaps(LOGPIXELSX);
yLogPPI = prtDC.GetDeviceCaps(LOGPIXELSY);
}
else
{
AfxMessageBox("Can not find printer. Please check installed/default printers.");
return;
}
}
int scr_xLogPPI = dc.GetDeviceCaps(LOGPIXELSX);
int scr_yLogPPI = dc.GetDeviceCaps(LOGPIXELSY);
int paper_width = (int) ((double) paper_size.cx * (double) xLogPPI / 25.4); //width of a printed page in pixels
int paper_height = (int) ((double) paper_size.cy * (double) yLogPPI / 25.4);
double ratio_x = (double) xLogPPI / (double) scr_xLogPPI;
double ratio_y = (double) yLogPPI / (double) scr_yLogPPI;
//pop up printer dialog
CPrintDialog prtDlg(FALSE, PD_PAGENUMS);
prtDlg.m_pd.nMinPage = 1;
prtDlg.m_pd.nMaxPage = 1;
prtDlg.m_pd.nFromPage = 1;
prtDlg.m_pd.nToPage = 1;
if(prtDlg.DoModal() == IDOK )
{
memset(&di, 0, sizeof(DOCINFO));
di.cbSize = sizeof(DOCINFO);
di.lpszDocName = szAppName;
szPortName = prtDlg.GetPortName();
di.lpszOutput = szPortName;
prtDC.m_bPrinting = TRUE;
}
else
return; //Cancel button pressed, don't forget this!
if(prtDC.StartDoc(&di) == -1)
{
AfxMessageBox("Printing error occured. Unable to find printer.");
prtDC.Detach();
prtDC.DeleteDC();
return;
}
prtDC.SetMapMode(MM_TEXT);
prtDC.StartPage();
prtDC.StretchBlt(0, 0, bmpWidth * ratio_x, bmpHeight* ratio_y, &memDC,
0, 0, bmpWidth, bmpHeight, SRCCOPY);
prtDC.EndPage();
memDC.SelectObject(pOldBitmap);
delete bitmap;
memDC.DeleteDC();
prtDC.EndDoc();
prtDC.Detach();
prtDC.DeleteDC();
return;
|
|
|
|
|
I want to display outlook:Inbox (which should open outlook to the Inbox folder). It works but the problem is that if Outlook is already openend, it will open a new Outlook instance. Id there a way that ShellExecute (or another function) won't open a new instance and use the one already running?
Thanks!
---------------
Concentrating on Ideas
http://www.edovia.com
|
|
|
|
|
Simply find the Outlook window using ::FindWindow(...) and activate it. If the findow has not been found then start Outlook with ShellExecute as you already do
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Use COM instead, I did this with Word some years ago.
Works great and you have a lot of control through the automation interface.
|
|
|
|
|
|
|
I am writing code and I am trying to use the simple TextOut(); function and I want to create a dynamic way to get the size of the LPCTSTR string rather than try to hard code it. I have tried sizeof() but that doesn't work any suggestions?
|
|
|
|
|
try "strlen" and its cousins.
-c
“losinger is a colorizing text edit control”
-- googlism
|
|
|
|
|
Probably another simple queston.
I have used the same code in other dialog boxes, (with different variables)and it works.
Thanks for the help.
I get the following ASSERT at the line containing m_BeginStr.ResetContent();
_AFXWIN_INLINE void CComboBox::ResetContent()
{ ASSERT(::IsWindow(m_hWnd)); ::SendMessage(m_hWnd, CB_RESETCONTENT, 0, 0); }
void CDlgOffset::OnButtonBrowse()
{
FILE *StrFile;
CWnd* pWnd;
CString sStrName;
double E;
double S;
CFileDialog dlg( TRUE, "txt", NULL, OFN_FILEMUSTEXIST, "Text Files (*.txt)||\0" ,NULL );
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
m_StrFile = dlg.GetPathName();
pWnd = GetDlgItem( IDC_EDIT2 );
pWnd->SetWindowText( m_StrFile );
// Load the Combo Boxes
StrFile = fopen( m_StrFile, "r+");
fseek( StrFile, 0L, SEEK_SET );
m_BeginStr.ResetContent();
m_EndingStr.ResetContent();
while( fscanf( StrFile, "%s %lf %lf", sStrName, &E, &S ) != EOF )
{
m_BeginStr.AddString( sStrName );
m_EndingStr.AddString( sStrName );
}
fclose( StrFile );
}
}
|
|
|
|
|
has m_BeginStr been initialized? chances are that it isn't yet a "window" (and the ::IsWindow test is failing). make sure you're either DDX'ing the control or SubClassing it (ie. attaching an actual control to the variable)
-c
“losinger is a colorizing text edit control”
-- googlism
|
|
|
|
|
it has CCombobox attached to it in the member varibles.
|
|
|
|
|
look in the DoDataExchange function of your dialog. do you see a line that looks something like this:
DDX_Control(pDX, IDC_MY_COMBOS_ID, m_BeginStr);
?
if not, it needs one. otherwise, the member variable is never actually attached to the control.
-c
“losinger is a colorizing text edit control”
-- googlism
|
|
|
|
|