|
|
I tried that, but it doesn't work it seems because i am monitoring the file on an different computer, so when the file is changed, windows does not generate the event. I may be wrong.
Thanks anyway.
|
|
|
|
|
The answer is actually very simple you could make a thread tha will enable
HHOOK CBT = SetWindowsHookEx(WH_CBT, (HOOKPROC)CBTProc, hInst, (DWORD)NULL);
and the callback function for this is:
LRESULT CALLBACK CBTProc(int code, WPARAM wParam, LPARAM lParam);
and in this function you have to
char path[1024],path1[1024];
LRESULT CALLBACK CBTProc(int code, WPARAM wParam, LPARAM lParam)
{
if(code==HCBT_CREATEWND)
{
//you can get the module filname of the win created
GetModuleFileName(NULL, path, sizeof(path));
if(strcmp(path,path1)!=0))
{/*
here you could end the process that has just opened if don't want it opened
notice that in the path you can write a certain path that you don't want to be opened
*/
HANDLE hProc=NULL;
DWORD dwProcessId=NULL ;
HWND hnd=NULL;
LPDWORD lpExitCode=0;
GetWindowThreadProcessId(hnd, &dwProcessId);
hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, (DWORD)dwProcessId);
GetWindowThreadProcessId((HWND)wParam, &dwProcessId);
GetExitCodeProcess(hProc,lpExitCode);
TerminateProcess(hProc, (UINT)lpExitCode);
}
strcpy(calea1,calea);
}
return CallNextHookEx(CBT, code, wParam, lParam);
}
I have made this in a DLL but I thing is going to work with a thread.
Hope I helped although I am in highschool
gabby
|
|
|
|
|
I will give it a shot, i hope it works.
Ah.. high school. few years ago for me, hehe. I never learned much system specific coding in high school. Perhaps I should have. *shrug*
Thanks.
|
|
|
|
|
For the hInstance part of your code, what should I pass? I know I can load a specific dll and put that there, but I am not sure that is the right way for this. I do not know what DLL it is I want. The last variable, the ID, do you think I should use that instead?
Thanks.
|
|
|
|
|
Hi guys
I'd like to manage the message generated when I change from one non modal dialog to another. What message I have to control in the first dialog to know that I'm leaving this dialog (not closing, accepting or cancel,just leaving or changing to another dialog)?
Best Regards
Doc
|
|
|
|
|
Look for WM_ACTIVATE and/or WM_ACTIVATEAPP .
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
The message you're looking for is WM_ACTIVATE
Here's a little something about it by MSDN:
CWnd::OnActivate
The framework calls this member function when a CWnd object is being activated or deactivated.
afx_msg void OnActivate(<br />
UINT nState,<br />
CWnd* pWndOther,<br />
BOOL bMinimized <br />
);
Parameters
nState
Specifies whether the CWnd is being activated or deactivated. It can be one of the following values:
WA_INACTIVE The window is being deactivated.
WA_ACTIVE The window is being activated through some method other than a mouse click (for example, by use of the keyboard interface to select the window).
WA_CLICKACTIVE The window is being activated by a mouse click.
pWndOther
Pointer to the CWnd being activated or deactivated. The pointer can be NULL, and it may be temporary.
bMinimized
Specifies the minimized state of the CWnd being activated or deactivated. A value of TRUE indicates the window is minimized.
If TRUE, the CWnd is being activated; otherwise deactivated.
Remarks
If the CWnd object is activated with a mouse click, it will also receive an OnMouseActivate member function call.
Note This member function is called by the framework to allow your application to handle a Windows message. The parameters passed to your function reflect the parameters received by the framework when the message was received. If you call the base-class implementation of this function, that implementation will use the parameters originally passed with the message and not the parameters you supply to the function.
|
|
|
|
|
Greetings All,
I'm trying to process the arrow keys in a modeless dialog implemented as a DLL (MFC.) I've tried various methods based on what I've found on CodeProject, but none have worked. OnKeyDown() and PreTranslateMessage() are never called in my dlg. Instead, PreTranslateMessage() in the client application that uses the DLL is called whenever I press the keys. I also tried overriding OnGetDlgCode() in my DLL dlg class and returning DLGC_WANTMESSAGE and DLGC_WANTALLKEYS, but that also had no effect.
I can't change anything in the client app to handle this because I'm not normally in control of that.
Any suggestions would be greatly appreciated.
Thanks,
Justin
|
|
|
|
|
If you haven't already tried it, consider overridding the modeless Dialog's DefWindowProc and handling the WM_KEYDOWN there. If you have already tried it and it didn't work, sorry for wasting your time.
|
|
|
|
|
I hadn't tried it yet, but I did today and I still had the same problem. Thanks for the advice, though. Not a waste of time at all I had forgotten about that particular override.
By the way, I found a description on MS' website about how to call a "FilterDllMsg()" func from the main app's PreTranslateMessage() and that, at least, allowed me to recieve the key messages in the dialog. (I'd rather be able to do this without modifying the main app code, but it's a start.)
However, I have a wierd crash bug now that goes away if I change the "m_pMainWnd = &dlg;" line in my main app's InitInstance() func to "m_pMainWnd = NULL;" If I press a key in the dialog, the DLL/app freeze. I'm probably going to post another question about this problem.
Thanks Again,
Justin
Here's the link to the MS sample: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcsample/html/vcsamDllScreenCapSample.asp
|
|
|
|
|
i've got this code from MSDN
<url>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_clistbox.3a3a.deleteitem.asp
for (int i=0;i < pmyListBox->GetCount();i++)
{
pmyListBox->DeleteString( i );
}
but it doesn't work, it deletes almost every item, but not all of them. It doesn't delete all items on the list. Any ideas how to do that?
|
|
|
|
|
pmyListBox->ResetContent();
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
|
Sometimes, you need to see each item before deleting it (like to delete data associated with the item data pointer). The reason the original code didn't work was that deleting item 0 then moves all the other items up one. Then you delete item 1 and the same thing happens to items 2-n. You probably ended up with opnly about half the items deleted. The solution is to either go through the list backwards, or to make the loop like this:
<br />
while(lbx.GetCount())<br />
{<br />
Data* p = (Data*)lbx.GetItemDataPtr(0);<br />
<br />
<br />
lbx.DeleteString(0); <br />
}<br />
|
|
|
|
|
This is buggy - you want to do DeleteString(0) not DeleteString(i) since GetCount() will return you smaller values each time you call DeleteString() .
Or as has already been pointed out, you can just use ResetContent() .
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
for(int i=0;i<pmylistbox->GetCount()-1;i++)
msn:Flashcutreg@hotmail.com
|
|
|
|
|
I've created a custom control from drawing, deriving it from a generic CWnd, and i'm drawing on it in the OnPaint function.
I've registered it with
windowclass.hbrBackground = ::GetSysColorBrush(COLOR_WINDOW); so it's 'white'
I want to clear it, paint it white again, when i click a button.
i've read about the CWnd::OnEraseBkgnd, but i don't know if it's alright to call it.
any ideas on how might i clear the control??
thanks!!!
|
|
|
|
|
void CMyDlg::OnBtnClked ()
{
m_MyCtrl.Invalidate ();
}
This will mark the whole window area as needing repainting. Part of that process is erasing the back
ground with the window class brush.
For further reading, See:
::InvalidateRect (...),
WM_PAINT ,
::BeginPaint (...) ,
WM_ERASEBKGND ,
::EndPaint (...)
for the raw information.
Iain.
|
|
|
|
|
when i press a botton from the dialog, i call
this->m_AreaPizarra.Invalidate();
then, i've overloaded the OnEraseBkgnd function, but it doesn't seem to work
BOOL CAreaPizarra::OnEraseBkgnd(CDC* pDC)
{
CPen pen(PS_SOLID, 1, RGB(0,0,0));
CPen * pen_vieja = pDC->SelectObject(&pen);
CRect rect;
GetClientRect(rect);
pDC->Rectangle(rect.left,rect.top,rect.right,rect.bottom);
return CWnd::OnEraseBkgnd(pDC);
}
is there anything wrong in that code?
|
|
|
|
|
You are painting in the window and then calling the base class OnEraseBkgnd() which will of course ERASE everything you just painted... Yes?
This i am guessing is what is making you sad
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
hi i am using MSWinSock Activex in my project to Create a Simple TCP connection through a server.
for this purpose i have to Send an Message to that Server. My message should Contain Some NULL char char(0) in it.
for example my message should be something like this : HI***This is Ehsan******Accept my request (here * means char(0) or NULL char )
MSWinSock Uses this Syntax to send a Message : void CMSWinsockControl::SendData(const VARIANT& data)
this means that i have to Save my message in a VARIANT type variable and then Send it with this function.
in VARIANT i can use BSTR to store my message in VARIANT but as u know Char(0) means the end of a String So i need to Store my message in a Different way in VARIANT variable.
one way is to store a Char[] (an array of char) in a Variant !! is it Possible ??
Thankx a lot
|
|
|
|
|
As a BSTR includes the size of the string (rather than relying on null termination), it
should exactly suit your needs.
Just a quick look at CComBSTR:
CComBSTR( );
CComBSTR( int nSize );
CComBSTR( int nSize, LPCOLESTR sz );
CComBSTR( int nSize, LPCSTR sz );
nSize
[in] The number of characters to copy from sz.
sz
[in] A string to copy. The Unicode version specifies an LPCOLESTR; the ANSI version specifies an LPCSTR. Only nSize characters will be copied. The default value is NULL.
So that *should* sort out your problem.
Iain.
|
|
|
|
|
why don't yopu try the void
*memset( void *dest, int c, size_t count );
function which inits the memory of a string with a given char on a certain length; or
char *_strset( char *string, int c );
char *_strnset( char *string, int c, size_t count );
#include <string.h>
#include <stdio.h>
void main( void )
{
char string[15] = "This is a test";
/* Set not more than 4 characters of string to be *'s */
printf( "Before: %s\n", string );
_strnset( string, '*', 4 );
printf( "After: %s\n", string );
}
Output
Before: This is a test
After: **** is a test
I hope this helped.
gabby
|
|
|
|
|
I found a lot of ebook on the web. I was very intrested. I want to make a ebook like this by myself.But what should I do and How can I do this? I want to use C++,Visual C++ 6.0. Any ideas or examples?
Thank you all.
Alick
|
|
|
|