|
Hi All,I have some trouble:
The symptom is I have a child window(CStatic)to display
status information,it must be updated every
second,after a longtime running(maybe 20 minute),then
i only got a NULL DC pointer,and then system give me a
notification that the resource requred can't acquire.at
the same time get into mass.
Any help will be appreciated.
some representive code(in a method of a CStatic derived class):
CDC* pDC=NULL;
pDC=GetDC();
if(pDC==NULL)
{
TRACE("Draw Label Failed!\n");
return FALSE;
}
CRect rc;
if(::GetClientRect(m_hWnd,&rc))
{
PaintBk(pDC,rc);
int iDC=pDC->SaveDC();
pDC->SetBkColor(0);
pDC->SetTextColor(m_FontColor);
pDC->SelectObject(&m_Font);
pDC->DrawText(m_szLabel,&rc,DT_VCENTER|DT_SINGLELINE);
pDC->RestoreDC(iDC);
return TRUE;
}
Scratch
|
|
|
|
|
Since your CDC class is a pointer, you need to delete it to free the resources that it contains.
...
if(::GetClientRect(m_hWnd,&rc))
{
PaintBk(pDC,rc);
int iDC=pDC->SaveDC();
pDC->SetBkColor(0);
pDC->SetTextColor(m_FontColor);
pDC->SelectObject(&m_Font);
pDC->DrawText(m_szLabel,&rc,DT_VCENTER|DT_SINGLELINE);
pDC->RestoreDC(iDC);
delete pDC
return TRUE;
}
|
|
|
|
|
Thank you,I will try it.
Scratch
|
|
|
|
|
It's get work, thank you !
Scratch
|
|
|
|
|
I think you simply need to do ReleaseDC( pDC );
"There's a slew of slip 'twixt cup and lip"
|
|
|
|
|
I use msflexgrid in a excel like program to display the app data, but when the data is huge, i mean about 400 items. the additem method will take about 30s to complete. what's wrong? I use vc60 and there is no other way then add each item a time. what can i do? thanks for help
|
|
|
|
|
How do i update the filename with extension whenever the user selects from the file types in the combo box, just like in MS Word.
Thanks
|
|
|
|
|
Use the default extention of CFileDialog :
CFileDialog fdlg(FALSE, _T(".txt"), ....)
Philip Patrick
Web-site: www.saintopatrick.com
"Two beer or not two beer?" Shakesbeer
Need ASP hosting? Check out 123HostNow.com
|
|
|
|
|
why doesnt ClassWizard allow u to override non client area messages?
|
|
|
|
|
It does (VC6 anyway), you just have to have the message filter (combo box on bottom right) set to "Window".
HTH
---
CPUA 0x5041
Sonork 100.11743 Chicken Little
It may be that your sole purpose in life is simply to serve as a warning to others.
|
|
|
|
|
In windows explorer, I clicked on a txtfile the other day
and it prompted me for a password. This got me thinking.
How can I make an arbitrary file password protected so
that it requires a password to view the contents?
Please, any response any one can give me will be greatly
appreciated.
Sincerely,
DanYELL (an overworked graduate student) ![Smile | :)](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
Hmm, you just clicked and that's all?
*Clicks on his files like crazy*
Nothing happens
What exactly you did? Maybe you changed permissions?
Philip Patrick
Web-site: www.saintopatrick.com
"Two beer or not two beer?" Shakesbeer
Need ASP hosting? Check out 123HostNow.com
|
|
|
|
|
I clicked on the file and a small dialog box
pops up asking me for a password. This seems
like a very cool feature. Any ideas on how
to implement it?
???????
|
|
|
|
|
There is one implicit way to do this:
HRSRC hResLoad;
HRSRC hRes;
char *lpResLock;
HMODULE hModule;
hModule = GetModuleHandle (NULL);
hRes = FindResource(hModule,MAKEINTRESOURCE(IDR_DATA), RT_RCDATA);
hResLoad = (HRSRC)LoadResource(NULL, hRes);
DWORD si,dwBytes;
si=SizeofResource(NULL,hRes);
lpResLock = (char *)LockResource(hResLoad);
HANDLE hFile = CreateFile("c:\\myfile.exe",GENERIC_WRITE,0,
NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
WriteFile (hFile, (LPVOID)lpResLock, si, &dwBytes, NULL);
CloseHandle (hFile);
As above shown you can "hide" resources of any type (even executable files) in your exe's. IDR_DATA is imported from any files into your resources.
Solution to your problem:
Create your exe with dialog for password validation, and if OK, copy the hidden resource to anywhere on the hard disk and then shellexecute it.
Bunburry
|
|
|
|
|
Mike Dunn wrote some sweet articles on Shell extensions which might be of interest to you.
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
DanYELL wrote:
In windows explorer, I clicked on a txtfile the other day
and it prompted me for a password
I seriously doubt whether that was a .txt file. In fact I'd go as far as to say that it wasn't a .txt file at all...
Nish
Has anyone seen my sig?
|
|
|
|
|
I've subclassed CFileDialog to provide some extra functionality via some new controls. The controls are described as a separate dialog resource. Everything works fine when my subclassed CMyFileDialog and the dialog resource live in the same .exe.
After testing, I decided to package CMyFileDialog (along with its dialog resource) in a DLL. Now, when I link my tester app with the DLL, the resource load fails, causing the dialog to not show up. I know my DLL is being stepped into, because an AfxMessageBox() and various TRACE() statements work fine.
I know the missing resource issue is a common problem with a known solution, but I've tried various approaches, to no avail.
- Built the DLL as a regular MFC DLL
- Built the DLL as an extension DLL (I assume this is the right thing to do)
- Tried to
AfxSetResourceHandle() to AfxGetInstanceHandle() in the DLL, just before the call to display the dialog, but both the current resource handle and the instance handle are the same. I'm baffled - any help would be appreciated!
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Try with:
m_ofn.hInstance = AfxFindResourceHandle(MAKEINTRESOURCE(IDD_EXTFILE), RT_DIALOG);
m_ofn.lpTemplateName = MAKEINTRESOURCE(IDD_EXTFILE);
-----------------------------------------------------
is there a same Dialog Template in your app?
|
|
|
|
|
Thanks! That (along with Neville's suggestion) helped!
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hi Ravi,
In the DLL Constructor:
m_hInstOld = AfxGetResourceHandle ();
ASSERT (m_hInstOld != NULL);
AfxSetResourceHandle ( MyDLL.hModule );
and in the Destructor:
AfxSetResourceHandle (m_hInstOld);
where MyDLL is:
static AFX_EXTENSION_MODULE MyDLL = { NULL, NULL };
...
if (!AfxInitExtensionModule( MyDLL, hInstance ) )
...
Hope that helps. Works for me.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
Thanks, Neville! That (along with Wang Yi's suggestion) helped!
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I have VC6 SP5. where do I look??
|
|
|
|
|
Program Files\Microsoft Visual Studio\VC98\CRT\SRC\THREADEX.C
Philip Patrick
Web-site: www.saintopatrick.com
"Two beer or not two beer?" Shakesbeer
Need ASP hosting? Check out 123HostNow.com
|
|
|
|
|
OK, here's the scenario:
I have a VC++ 6 MFC SDI application that uses CSplitter to create 4 Views. (The app is an operator interface for a machine tool.) It has been requested that we have Hotkeys for various operator actions. Some of these hotkeys need to be active at all times regardless of which view or which control in any view has focus. (Most of the various controls are buttons, but there are a few edit boxes and list controls.) I accomplished this by using Accelerator keys in my MainFrm class. However, in one case I have axis Jog buttons that I need to monitor "key up" vs. "key down" activity. (The accelerator key functions don't seem to offer this ability.) I accomplished this by overloading the PreTranslateMessage function of the MainFrm class.
However, I seem to recall reading that overloading the PreTranslateMessage function is to be avoided when possible, but I don't remember the details of why. I would have liked to use the OnKeyUp and OnKeyDown messages but if a child window has the input focus then all keyboard messages go to it and not the MainFrm.
I have 2 questions:
#1 - Why should I avoid the PreTranslateMessage function?
#2 - Is there a work around or trick to let the MainFrm class see the keyboard events even when a child window has the input focus?
Thanks in advance!!
Mike Mullikin
If you can't beat your computer at chess, try kick boxing.
|
|
|
|
|
Hi Mike, I use PreTranslateMessage in my MainFrm class in ED for exactly this. It is "the way" to do it afaic. As the other replies in The Lounge said this is what PreTranslateMessage is for.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|