|
Here is a solution not using StretchBlt() and using memDC.CreateCompatibleDC(NULL) with argument NULL.
int CListCtrlPrint::PrintBitmap (CDC *pDC, CRect rcBmp)
{
// this function prints bitmap
BITMAP bm;
CBitmap Bitmap, *pOldBitmap;
CDC memDC;
int nW, nH;
Bitmap.LoadBitmap (IDB_BITMAP2);
Bitmap.GetBitmap (&bm);
nW = bm.bmWidth;
nH = bm.bmHeight;
memDC.CreateCompatibleDC(NULL); // NULL !
pOldBitmap = memDC.SelectObject(&Bitmap);
pDC->BitBlt(rcBmp.left,
rcBmp.top,
rcBmp.left + nW,
rcBmp.top + nH,
&memDC, 0, 0, SRCCOPY);
memDC.SelectObject(pOldBitmap);
return (nH);
}
Preview and print ok, but bitmap very small (expand bitmap with Paint ...)
|
|
|
|
|
not all printers support StretchBlt. use GetDeviceCaps to test. if it doesn't support StretchBlt, you'll have to use StretchDIBits.
to fix the 'small image' problem, see SetViewportExt, SetWindowExt and SetMapMode.
-c
Smaller Animals Software, Inc.
|
|
|
|
|
Hi all!
How data could be displayed in db grid control using ado are some other technique.Is there anyone who can help me!
Thanks:
imran
|
|
|
|
|
I create a DIALOG project,and put a Edit control on the dialog,then define a variable through DDX:CEdit m_edit;
I create another class in the project,in this class, I want to give the variable 'm_edit' of the dialog a value,so I:
CMyDlg dlg;
dlg.m_edit.SetWindowText("sdjsd");
//or
CMyDlg* dlg;
dlg->m_edit.SetWindowText("sdksdlk");
The two method above is all wrong,help me plx,thanks very
much.
I want to know how to deal other dialog's content.
|
|
|
|
|
1) This is a wholly bad idea. The dialog should be the one changing it's fields, not an external object.
2) If you insist on proceeding this way, you would do something like this:
CEdit* CMyDlg::GetEditCtrl()
{
return (&m_edit);
}
CMyDlg dlg;
dlg.GetEditCtrl()->SetWindowText("sdjsd");
Again, this is a REALLY bad way to set the contents of a control in a dialog box.
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I have been racking my brain for a while now trying to make my program track down the size of a folder/file. I would like to track how much space a folder is using on the hard drive, which I have determined that means recursing through the sub folders and adding up the size of all files... Ugh! Is there an easier way? If not, the problem I'm running into at this point is simply finding the size of the file! I've looked into every which way of find the file sizes and they all want some variable/handle that I don't have... I've been looking through the code for the tree's here and have found some very nice tips and stuff, but of course (as always) they are in dialog boxes with special controls, yadda yadda yadda. (Doesn't anyone else use MFC with a doc/view?) But I'm not seeing how to add up the size of files and stuff. Please, someone help me out. I'm getting frustrated to the point that I can't even explain it right
Programming in binary is as easy as 01 10 11.
|
|
|
|
|
G'Day Greven,
Maybe I have mis-understood what you are trying to do but you can use CFindFile to recurse sub directories. CFindFile has a member function GetLength() which returns the size of a found file. So it is easy to step through a directory and work out its size
something like will come close (cut and pasted from existing code so I may have chopped some bits out but you should get the drift)
TraverseDirectory(CString strDirectory)
{
int nBytes = 0;
BOOL bWorking = finder.FindFile(strDirectory);
while (bWorking)
{
bWorking = finder.FindNextFile();
strFileName = finder.GetFilePath();
if (finder.IsDirectory())
{
if (!finder.IsDots())
TraverseDirectory(strFileName);
} else {
nBytes = finder.GetLength();
}
}
You can also use GetDiskFreeSpaceEx to determine free space information.
Hope that helps.
Richard.
|
|
|
|
|
That is exactly what I have been looking for... Thank you very much. And you know the worst part? I've used CFindFile many times before... Just never noticed the GetLength() function... (maybe it's just a really bad name for it
Programming in binary is as easy as 01 10 11.
|
|
|
|
|
You can also use CFile::GetStatus() to get the size of any file.
/ravi
"There is always one more bug..."
ravib@ravib.com
http://www.ravib.com
|
|
|
|
|
Hi there
I have MDI application.
Child MDI window consists of CMDIChildWnd and CView.
What events and what situation I should handle in
CMDIChildWnd and what I should handle in CView?
Second question, if I need to change size of CView then
I have also change
size of CMDIChildWnd, is it true?
In CView I inserted CPropertySheet and I need to make size of child MDI
window the same as size of inserted CPropertySheet, what is the right way to do it?
|
|
|
|
|
how can i change the SELECTION color of an edit?
(the default color looks bad with my custom ui )
thanks in advance
|
|
|
|
|
|
actually i mean the background color of selected text
(any other than rgb(0,0,128) which is the default color for that)
any ideas ?
|
|
|
|
|
Hi,
I have a complicated (to me) problem reading/Writing data in binary. Here is what I am doing.
For example let say a text file has the following:
File: test.txt
-----------------
1234a5678b9
-----------------
Here is what I am doing:
istream inData;
ostream outData;
inData.open("test.txt", ios::in | ios::binary);
outData.open("modified.txt", ios::out | ios::binary);
inData.seekg(0, ios::end);
int size = inData.tellg();
char *temp;
temp = new char[size + 2];
inData.read(reinterpret_cast<char *="">(temp), size);
temp[size + 1] = 'c';
temp[size + 2] = 'd';
outData.write(reinterpret_cast<char *="">(temp), (size + 2);
-----------------------------------------------------
The code above should work okay. As you can see, all I am doing is reading data from a file, add two characters "c" and "d" and then writing it back to the file. Everything is fine.
Now, let say I read the modified file back.
Here is what I am doing:
istream modData;
ostream weird;
modData.open("modified.txt", ios::in | ios::binary);
weird.open("hungry", ios::out | ios::binary);
inData.seekg(0, ios::end);
int size = inData.tellg();
char *temp, charA, charB;
temp = new char[size];
inData.read(reinterpret_cast<char *="">(temp), size);
charA = temp[size - 2];
charB = temp[size - 1];
-----------------------------------------------------
Do you see what I am trying to doing?
1)read fileA in binary
2)save data from fileA to tempX
3)add characters to tempY
4)write temp to fileB
-----------------------
1)read fileB in binary
2)save data from fileB to tempZ
3)extract ONLY those characters I added to tempX from tempZ
-----------------------
The method I use to extract the added characters from the modified file after I read it back is subscript. I assume let say temp[5] is 'a'. When I read the data back, I look at temp[5].
My question is when you read a file in binary, add characters to it in specific spaces and write it to modified file, is it possible to read the data from the modified file and extract those characters you added via assumption subscript? How are data saved when you read and write in binary?
Thanks,
Kuphryn
|
|
|
|
|
I see some problems with what you are doing.
First, arrays are zero-based. To append two characters to the end of an array of size means you write to temp[size] and temp[size+1]. The write command with (size+2) is then correct. Accessing [size+2] means you must allocate and write (size+3) items. The last of the original data will be at index (size-1).
To extract only the characters you added then seek to position size on your input stream and then read 2 items.
|
|
|
|
|
Interesting. Thanks.
I got everything write. When I read teh modified data back, sometimes it comes out right and sometimes it does not. I do not know if it is writing the modified file differently everytime.
Kuphry
|
|
|
|
|
Is possible to rebuild IntelliSense ASC stores found in <msvs-root>\Common\MSDev98\Bin (Win32.ncb, Mfcatl.ncb and Crt.ncb) ? Simply deleting them only disables code editor's IntelliSense features
I'd needed to recreate them because they contains in some instances improper data, f.E. incorrect number of function parameters, wrong return type etc. - it could be very confusing.
Does anybody know how to solve this problem or knows something about internal format of .ncb files ? I know there is a good replacement called Visual Assist from WholeTomato software but it isn't free
Thx
Cernd
|
|
|
|
|
In my SDI MFC app there's a CMainFrame, and I don't want it to be resizable. How I can do that? Thanks for the help
|
|
|
|
|
Remove the WS_THICKFRAME style
Nish
|
|
|
|
|
Where can I find it??? in the CREATESTRUCT cs??? In the MSDN there isn't any help for the CREATESTRUCT
|
|
|
|
|
Hi,
I need to know that whether its possible to have server based on WinSock and Client based on CAsyncSocket?
I tried so but did not succeed.. Before i put my full efforts i need to nkow if it is possible or not..
If there is something special work needed to be done to make it work, then do specify it..
Thanking u in advance
RawCoder
|
|
|
|
|
|
If you have a network (LAN), go to your network connections in Control Panel and right click on the Local Area Connection (or whatever you have there). You can make it "Enable" or "Disable" (connect or disconnect). Now my question is how to do this programmatically in Windows 2000? I was looking in MSDN and didn't find nothing.... Change user info, get domains.... all what you want but not something like Connect or Login.
IF someone knows the answer, please tell me
Thanx
Philip Patrick
|
|
|
|
|
- Can you help?
- Regards,
Maer
|
|
|
|
|
if you are asking about #ifndef then the main difference is the #if form permits complex expressions such as :
#if( !define(THIS) && !define(THAT) && !(THE_OTHER_THING) )
I don't believe that #ifndef supports this type of expression. It may but I have never seen any.
|
|
|
|