|
Exceptions are your friends!
I suggest, do what peter says.
However, if you do want to try:
Use a function to return the object instead of doing it with "new". Such a concept is usually called a "Class Factory" (concept from COM), whose sole purpose is to create and return an instance of a class.
void *CreateClassAA(string a)
{
if(a == "")
return 0;
else
.............
}
Bikram Singh
|
|
|
|
|
Yes this is a good idea.
But how is it done in ifstream? Does it really work fine?!
Thanks
Michael
|
|
|
|
|
hi,
i have a dialog box with a static control. the problem is that when i try to use setbkcolor for the static control in oninitdialog of the dialog box, it does not produce any results. i have tried to use GetDC() for the static control to get the DC. and then tried to set the background color of the static control. can any one give me a solution?
regards,
kevin
|
|
|
|
|
|
using WM_CTLCOLOR causes problems in other parts of my code. is there any other solution?
|
|
|
|
|
It should not affect other parts of your code.
Here is a sample of my code.
HBRUSH CMyView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor);
INT nIDCtl = pWnd->GetDlgCtrlID();
switch(nIDCtl)
{
case IDC_STATIC_CTRL1:
{
pDC->SetBkColor(RGB(255, 255, 255));
CBrush br;
br.CreateSolidBrush(RGB(255, 255, 255));
hbr = (HBRUSH)br;
br.Detach();
}
break;
case IDC_STATIC_CTRL2:
....
....
case IDC_STATIC_CTRL3:
....
....
case IDC_STATIC_CTRL4:
....
....
}
return hbr;
}
|
|
|
|
|
|
SetBkColor() should be used when handling a WM_PAINT message or within a control's DrawItem() override. Use it to set the background color of the DC for the duration of the painting action.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
even if i use setbkcolor in WM_PAINT is does not do anything.
|
|
|
|
|
I have a SDI project where a user using the menu can select and load another window object. I get the new window, but it is on top of my main window. I want to be able to move the window away from the main window.
This is the code I use to create and show the window:
pStatus->dlg.Create(IDD_FORM_STATUS);
pStatus->dlg.ShowWindow(SW_SHOW);
Can someone help me out?
Thanks.
Jerry
|
|
|
|
|
One solution is MoveWindow().
Kuphryn
|
|
|
|
|
hi!
im a newbie with MFC & hope someone can help me with this...
i hv created 2 MFC dialog based programs and need to integrate them together... ie. after integrating, when i click on build on execute, the 2 dialogs shld appear together on the screen.
i've tried using a modal dialog box in program A so as to contain program B but created a mess n it's not functioning too.. as the 2 dialog dialog boxes need not communicate w each other, i wonder if there is a better suggestion?
|
|
|
|
|
Use Modeless Dialogs...
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
Hi!
I have projects and DLLs made with Visual C++6 and I try to pass to Visual C++7.
I have a link error when I use a function (contained in a DLL) that uses a CString as parameter.
ERROR LINK 2019 non resolved symbol CStringT ...
Everything was alright with VC++6.
How to solve my link problem?
Will any other problems happen soon during the passing of VC++6 to VC++7???
Thanks.
|
|
|
|
|
Hi all
does ne1 know the easist way of deleting a file
i have a txt file which i need to remove in certain situations
i tried using
remove(str_SettingsPath);
but that doesnt work
any ideas ??
si
|
|
|
|
|
Use unlink() , CFile::Remove() or DeleteFile() . Be sure to specify the file's full pathname.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
si_69 wrote:
i tried using
remove(str_SettingsPath);
but that doesnt work
It should, if used correctly. What value does it return? The file must not have the read-only (and probably the hidden) bit set. You must also have the right privileges.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
silly me, still had the file open while i was trying
to delete it
|
|
|
|
|
I first selected some files from an input directory, and then set the output directory to be some other location. Then I processed my input files and had it do a system() call for "dir/b > list.txt".
Its odd that it created the list.txt in the input files directory . I also checked with getcwd and sure enough it was the input directory. What is the reason for this?
Thanks,
sb
|
|
|
|
|
Working directories are specific to a drive. You're much better off using an API to get the list of files in a dir instead of calling system() .
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Ravi Bhavnani wrote:
...instead of calling system().
Agreed.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
How did you select the output directory? dir /b > list.txt WILL create a list.txt file on the current working directory. I am just curios to know how you set the output directory because there is no such function as setcwd(), unless you used chdir(). But if you did that then dir /b list.txt will work only on the new directory.
On the other hand, "dir /b > C:\...\outputDir\list.txt" will do the trick and probably you knew that already. "dir" command will take as parameters the full path to the input directory and the full path to the output directory.
i.e. dir c:\...\inputDir /b > c:\...\outputDir\list.txt
Some code posted here would help.
But just as the others did, I would recommend API.
// Afterall, I realized that even my comment lines have bugs
If the sun were to blow up, it would take us 7-8 minutes to realize it.
|
|
|
|
|
Hi all,
I want to track the printer messages send by any application.
I want to do this using windows Hook... but I dont know which Hooking message i should use here...
If anybody knows this please help me...
Thanks
|
|
|
|
|
Try the WH_CALLWNDPROC, WH_CALLWNDPROCRET or the WH_GETMESSAGE hook types.
Look for a message id of WM_PRINT.
Bikram Singh
|
|
|
|
|
I already use that, but it is not working....
I get the WM_PRINT message when i just click on the menu... and not when i press print command from menu...
I don’t know how this is happening...
Hear is my code...
LRESULT CALLBACK HookProc(int nCode, WPARAM wParam, LPARAM lParam)
{
// return immediately if system required
if (nCode < 0){
return CallNextHookEx(g_hInitMenuHook, nCode, wParam, lParam);
}
// get window procedure struct
CWPSTRUCT *wps = (CWPSTRUCT*)lParam;
switch(wps->message)
{
case WM_PRINT:
/// code for loging the print command
break;
}
return CallNextHookEx(g_hInitMenuHook, nCode, wParam, lParam);
}
I tried this HookProc for both WH_CALLWNDPROC and WH_GETMESSAGE... but it is not working
Can anybody suggest me any other way to trace the Print Command
Thanks
|
|
|
|