|
I have a drawing application and am trying to implement a print scaling feature much like Excel's "page setup" so the resulting print-out can be scaled accordingly.
For example, I have tried the below code to print a bar graph, but see no effect on neither the print-out nor the print preview result.
What am I doing wrong? Any help would be greatly appreciated.
OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
{
HDC temphd = CreateCompatibleDC( pDC->m_hDC );
StretchBlt( pDC->m_hDC, 0, 0, 32, 32, temphd, 0, 0, 100, 100, SRCCOPY );
DeleteDC( temphd );
}
Best regards,
tak shichiku
|
|
|
|
|
I have scaled stuff 3 different ways:
1.) Acually recalculate the sizes of rects and other objects before display or printing them.
2.) Draw to a memory DC and StretchBlt to the display or printer. (This looks like what your where hoping to do.)
3.) Use the windows mapping functions.
Option 1 works if everything you are displaying can be put in rectangles. You have to multiply all the coordinates by a scale factor before displaying them.
Option 2 works, but you are stretching a bitmap so you get poor results if stretching too big or too small. To make this work you have to; create a memory DC, create a Bitmap, select the Bitmap into the memory DC, draw on the memory DC, then StretchBlt or BitBlt to the display DC or printer DC.
Option 3 works well also. You have to use the CDC::SetMapMode, CDC::SetWindowExt, and CDC::SetViewportExt methods. I can't tell you how to use these because you have to understand the WindowExtent and Viewport consecpts. But this information can be fould in the MSDN. This may be your best bet, because you can get scaling without changing all your drawing code.
Hope this helps...
Jonathan Craig
www.mcw-tech.com
|
|
|
|
|
Hi,
I have a handle to a bitmap(not a resource bitmap) file and can display it in my app window. Now I need to search all pixel RGB values if necessary change them with another RGB value and display it again.
I know a BITMAP structure have bmBits pointer but do not know how to use it.
karanba
|
|
|
|
|
I don't believe the bmBits is valid if it's not a DIBSection, but depending on the bit depth, they are stored as BGR, BGRA, or 5 bits each of BGR plus one bit for padding. They are stored in rows that are a multiple of 4.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
what is DIBSection, I hear much about?
karanba
|
|
|
|
|
basically, a DIBSection is a DIB that can act like an HBITMAP. you can get at the pixel data as you do in a DIB, but you can use it in functions liek BitBlt, like an HBITMAP.
-c
There ain't no second chance
Against the thing with the forty eyes, girl
|
|
|
|
|
Hi,
In my application, I have some classes which
also use some MFC classes.
what effect would it make if i Convert those Classes to
ATL objects.
I am new to ATL, so please excuse me if there is some
technical glitch..
Please help
Sameer
|
|
|
|
|
By convert do you mean to remove the MFC parts, or do you use MFC with ATL ( which is evil ) ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Actually it is MFC + ATL.. some components of ATL..
But how can i convert my full project to ATL.. and also
can i handle OnTimer() an d messages in ATL..
Please suggest me some sites also..
Thanx
Sameer
|
|
|
|
|
I am trying to add/modify the columns and rows of ClistCtrl, when i compile the code there are no errors but when i run the program its giving some error message 'Illeagal Operation'..
My code is as follows:
for(int c=0; c< nColumnCount; c++)
m_lc.DeleteColumn(0);
//here m_cols is the integer value entered by the user
//and m_rows is also an integer value entered by the user
//m_lc is the ListControl variable
if(m_cols > 0)
{
LV_COLUMN lvcol;
lvcol.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM;
lvcol.fmt = LVCFMT_LEFT;
lvcol.cx = 80;
CString s;
for(int c=0; c<m_cols; c++)
{
s.Format("Coloum %d",c+1);
lvcol.pszText = (LPSTR)(const char *)s;
lvcol.iSubItem = c;
m_lc.InsertColumn( c, &lvcol );
}
}
The above code i used to delete the existing columns and add new columns which is working fine
but when I tried to add the rows i am getting the error message.
The following is the code i wrote to add the row data
CString s;
for( int i = 0; i < m_rows; i++)
{
LV_ITEM lvitem;
lvitem.mask = LVIF_TEXT | LVIF_PARAM;
lvitem.lParam = 0;
lvitem.iItem = 0;
s.Format( "subitem %d", 0);
lvitem.pszText = (LPSTR)(const char *)s;
lvitem.iSubItem = 0;
int r = m_lc.InsertItem( &lvitem );
for(int c = 1; c < nColumnCount; c++)
{
s.Format( "subitem %d", c);
BOOL b = m_lc.SetItemText( 0, c, (LPTSTR)(const char *)s);
}
}
Can Any one Help me in doing the above??
Thank you.
|
|
|
|
|
If I add buttons while application initialization CToolBar will resize well. But if i do it in the midle of my program there is no CToolBar resizing (but buttons i can see new buttons). If I minimize and then maximiza application, then CtoolBar size will be recalculating an all OK.
Please help me. I was trying to use different pToolBarCtrl->Invalidate and pToolBarCtrl->AutoSize(), but there is no any changes.
|
|
|
|
|
Call the RecalcLayout() method on the parent frame.
--------
I don't think that I'm a sell-out but I do "Enjoy Coke!"... -- Bloodhound Gang, The Inevitable Return Of The Great White Dope
|
|
|
|
|
|
Hi !
I'm building an ATL App with VC++ 6.0.
I added a dialog in my app with the 'Insert->New ATL Object->Miscellaneous->Dialog'.
Then, using the resources editor, I put in this new dialog a CListBox control.
Then, during the InitDialog, I try to add strings to this CListBox control using :
CListBox* pList=(CListBox*)GetDlgItem(IDC_LIST);
pList->AddString("hi");
It compiles fine, but when I run it, I get an assertion failure at the line 'AddString'.
Anyone could help me ?
Thank you !
Jerome
|
|
|
|
|
Hi,
I tried ATLCONTROLS.H ( or whatever name), to get the sugar control classes, but I had some problems as well, have you tried, the "attach" method to attach the HWND.
I rather use, ::SendMessage stuff, when you get used to it it´s not so bad, the message for adding one string is:
LB_ADDSTRING
So something like:
SendMessage(
(HWND) hWnd,
LB_ADDSTRING,
(WPARAM) wParam,
(LPARAM) lParam
);
HTH
Braulio
|
|
|
|
|
Hi,
How do we minize a dialog at the startup i've tried to use
showwindow(SW_MINIMIZE)
in the initdialog but with futile results has anyone done this before will be grateful for any help
Thanks.
|
|
|
|
|
The easiest way is to create the dialog with the WS_MINIMIZE style. One way to do this is to add this style to the dialog template. You may need to edit the .rc file directly in order to do this.
--------
I don't think that I'm a sell-out but I do "Enjoy Coke!"... -- Bloodhound Gang, The Inevitable Return Of The Great White Dope
|
|
|
|
|
Oops! i checked it out an it hasn't worked. or may be is there a way to hide the dialog at the statup.
|
|
|
|
|
Yes, I'm still fumbling around with the basics of MFC. I've got a CSettings class of which I declare an instance "settings" as a member of CMyApp.
So I've got:
class CMyApp : public CWinApp<br />
{<br />
public:<br />
CSettings settings;<br />
}<br />
When someone selects Settings... from the menu, the framework calls CChildView::OnFileSettings().
How can I access the settinngs I've got stored in CMyApp::settings ? AfxGetApp() just returns a pointer to the base class, CWinApp.
Confused.
- Jason
(SonorkID 100.611)
"I just recieved an email from myself but I didn't send it ?"
- Colin Davies, Sonork conference
|
|
|
|
|
Well, there's probably a global variable named theApp around somewhere, otherwise just cast the return value of AfxGetApp() to a CMyApp* [edited: yeah, forgot about the <> thing):
CMyApp* pApp = static_cast<CMyApp*>(AfxGetApp());
--------
I don't think that I'm a sell-out but I do "Enjoy Coke!"... -- Bloodhound Gang, The Inevitable Return Of The Great White Dope
|
|
|
|
|
Just do this ...
CMyApp * pApp = (CMyApp*)<code>AfxGetApp()</code>;
Best regrads,
Eugene Pustovoyt
|
|
|
|
|
The cast of the AfxGetApp will work but I think its a problem of the architecture. Why you should one (of many) CChildView objects modify an element of the app?
IMHO: delete the "CChildView::OnFileSettings()" and create the OnFileSettings() -Message-Handler in the Mainframe or App class.
|
|
|
|
|
I use COXHyperLink from Dundas Ultimate Toolbox to display two links. In Win2K/XP I have following problem: by default, this OS hides underlied letters on buttons/menus (these letters used for quick access with Alt, for example &Close). When I press Alt key, captions became underlined. COXHyperLink uses subclassing of static control.
TROUBLE:
After Alt pressing hyperlink disappears, and only gray background is visible. How can I fix the problem by myself?
See image here
|
|
|
|
|
Hi there,
I have tested the latest version of this class, and I was not able to replicate the issue you have indicated. I was also not able to view the image you have linked to, please contact Dundas Tech Support, lets work together to locate and resolve this issue.
Peter
Dundas Technical Support
|
|
|
|
|
=======================================================
Win32 Debug
-------------------------------------------------------
Generating Code...
Linking...
Creating browse info file...
AhMan_Language_Swap.exe - 0 error(s), 0 warning(s)
========================================================
========================================================
Win32 Release
-------------------------------------------------------------
Linking...
msvcrt.lib(MSVCRT.dll) : error LNK2005: _sprintf already defined in LIBCMT.lib(sprintf.obj)
msvcrt.lib(MSVCRT.dll) : error LNK2005: __itoa already defined in LIBCMT.lib(xtoa.obj)
msvcrt.lib(MSVCRT.dll) : error LNK2005: __setmbcp already defined in LIBCMT.lib(mbctype.obj)
msvcrt.lib(MSVCRT.dll) : warning LNK4006: _sprintf already defined in LIBCMT.lib(sprintf.obj); second definition ignored
msvcrt.lib(MSVCRT.dll) : warning LNK4006: __itoa already defined in LIBCMT.lib(xtoa.obj); second definition ignored
msvcrt.lib(MSVCRT.dll) : warning LNK4006: __setmbcp already defined in LIBCMT.lib(mbctype.obj); second definition ignored
Creating library Release/AhMan_Language_Swap.lib and object Release/AhMan_Language_Swap.exp
Release/AhMan_Language_Swap.exe : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.
AhMan_Language_Swap.exe - 4 error(s), 3 warning(s)
==============================================================
Why error in release compile but not in debug compile
|
|
|
|