|
Thanks for your answer.
Finally, I have detected the problem with m_lpComdLine in using the class CCommandLine I have found on codeproject.
it seems MSDN talks about this supplementary space but it is not very clear.
I have had difficulties to detect my problem because I use only one parameter and in this case, the m_lpCmdLine contains nothing.
Regards.
HF
|
|
|
|
|
Hello HF,
Most welcome, HF. Glad to be of any help.
Regards,
Bio.
|
|
|
|
|
Hi All,
I'm just playing really, trying to make a skinned app. Success so far from painting my own background, using a non-rectangular window region, and painting non client areas myself.
Thing I can't figure out though is how to make funny sized/shaped non client areas, such as title bar. I can't find a way to change the size at all.
Any ideas??
Jon
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
See:
/ravi
"There is always one more bug..."
ravib@ravib.com
http://www.ravib.com
|
|
|
|
|
Hi,
I have a DIB that i want to extract a particular region from. So basically i am cropping the DIB.
My problem is i don't want to do this through a DC. Reason been if i have monochrome DIB, selecting it into a device context which is compatible with the screen result in a 24bps image.
Can anyone offer me any advice?
Thanks Again
Richard
|
|
|
|
|
to do this reliably, you'll have to know how to parse all of the different DIB formats - or at least the formats that you know you'll be working with. while this isn't an impossible task, it's certainly not simple. with monochrome (or < 8bpp) you're going to have to do a lot of bit masking and shifting to get at the individual pixels - yuck. things get even worse, if there's the chance you'll be working with RLE DIBs.
but, you can create monochrome DCs, if you want to just use the BitBlt stuff. search the MSDN for "create monochrome DC". it's easy.
-c
Smaller Animals Software, Inc.
|
|
|
|
|
Has anybody used MySQL via MFC? If so please point my in the right direction. Example code / db would be very useful..
"Life begins at 140"
|
|
|
|
|
Use MySql's odbc drivers. You can get these from mysql.com. Then it's just like programmign any odbc source.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Hello
Printing a bitmap using the fraction of code below fails. The bitmap is visible in the preview mode.
int CListCtrlPrint::PrintBitmap (CDC *pDC, CRect rcBmp)
{
BITMAP bm;
CBitmap Bitmap, *pOldBitmap;
CDC memDC;
int nW, nH, nDstW, nDstH;
BOOL bRC;
Bitmap.LoadBitmap (IDB_BITMAP2);
Bitmap.GetBitmap (&bm);
nW = bm.bmWidth;
nH = bm.bmHeight;
memDC.CreateCompatibleDC(pDC);
memDC.SetMapMode(pDC->GetMapMode());
pOldBitmap = memDC.SelectObject (&Bitmap);
nDstW = nW * 10;
nDstH = nH * 7;
CRect rc(rcBmp.left, rcBmp.top, rcBmp.left + nDstW, rcBmp.top + nDstH);
pDC->StretchBlt(rcBmp.left,
rcBmp.top,
nDstW,
nDstH,
&memDC, 0, 0, nW, nH, SRCCOPY);
memDC.SelectObject(pOldBitmap);
return (nDstH + 75);
}
Has anybody any idea what's the problem ?
Thanks
|
|
|
|
|
Could you be more specific? I.e. where does it fail when you step thru the code?
/ravi
"There is always one more bug..."
ravib@ravib.com
http://www.ravib.com
|
|
|
|
|
Hi Ravi,
I do not know where it fails. Looking to the the code below, there are to bitmaps. Loading the resource ID, you see the bitmap on preview, but does not print.
Using the compatible bitmap, I only see a black rectangle and I do yet not know how to load the bitmap here. But this black rectangle is printed.
int CListCtrlPrint::PrintBitmap (CDC *pDC, CRect rcBmp)
{
BITMAP bm;
CBitmap *pBitmap, *pOldBitmap, Bitmap;
CDC memDC;
int nW, nH, nDstW, nDstH;
BOOL bRC;
Bitmap.LoadBitmap (IDB_BITMAP2);
Bitmap.GetBitmap (&bm);
nW = bm.bmWidth;
nH = bm.bmHeight;
memDC.CreateCompatibleDC(pDC);
pBitmap = new CBitmap;
VERIFY(pBitmap->CreateCompatibleBitmap(pDC,nW,nH));
pOldBitmap = memDC.SelectObject (&Bitmap);
//pOldBitmap = memDC.SelectObject (pBitmap);
nDstW = nW * 8;
nDstH = nH * 5;
bRC = pDC->StretchBlt(rcBmp.left,
rcBmp.top,
rcBmp.right + nDstW,
rcBmp.bottom + nDstH,
&memDC, 0, 0, nW, nH, SRCCOPY);
if (!bRC)
AfxMessageBox(_T("Bitmap not drawn"));
memDC.SelectObject(pOldBitmap);
delete pBitmap;
return (nDstH + 75);
}
Perhaps this helps.
|
|
|
|
|
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
|
|
|
|
|