|
i want a flag window equivalent to visual foxpro for one of my SDI apps. that must popup on the top right corner of my framewindow, that must grow/shrink according to the content, and that must be vanish when one of the keystrokes occures.any code for that???
i wanto to invoke that like
object.FlagMessage("Hello Chris");
help me.!!!
i've no time to write one from scratch . so pls help me...
[to all lnstant article GURUS..!!.this is your turn to help me out of this..]
mind is everything.
|
|
|
|
|
You will get more help, much faster, if your subject line is more useful than this. Something like "popup tied to corner of framewindow". I rarely look at "Need Help" or "Please Help" or the like. If you cannot be bothered to give a subject, who will be interested in looking at your question?
Also, we are all busy and writing code on demand for you is unlikely to happen.
Good luck!
|
|
|
|
|
Thankyou Harold Bamford,
i posted this same with a specific subject one day earlier, but no response at all..!!!!!!
but i need this very urgently, i hope i can find a temperory solution for the time being...but will be very thankfull to you guys if you can help me ...
mind is everything.
|
|
|
|
|
I am developing a program much like FlashGet or GetRight...
It successfully downloads files but when I got to the part making it
download the files into segments, I got myself in trouble...I use
synchronous downloading, but after I start the 5 segments, just 2 of them
pass the part "HttpSendRequest" and starts downloading their parts but the
other 3 just stay there and waits for something even after the other 2
threads finish their work....after a while they either start downloading,
either fail - as they got no response(it timed out)...
After walking over the net I found that there is asynchronous downloading
too, and I'm forced to try it since the way I do it(HttpSendRequest and
InternetOpenUrl fails too) doesn't work...
I open a internet session with the async flag, then I set a status
callback function for the session. Then I call InternetOpenUrl, and I got
a NULL handle. Then I check weather the last error is ERROR_IO_PENDING and
if so I make the thread to wait for a event. That event is being signalled
by the Status Callback when it got a STATUS_RESPONSE_COMPLETE status, and
in the struct passed in the dwContext value of InternetOpenUrl(its a
struct) I set up the handle to the file.
But here's the problem...
After the thread waits for the event to get signalled, the status callback
receives just 1 status - STATUS_HANDLE_CREATED and then just crashes...
the code where it crashes is indicated in wininet.dll with a Access
Violation!
Here's source code:
PSTATUSCALLBACK hStatusCallback;<br />
hStatusCallback.nSegment = pSegment->m_nSegment;<br />
hStatusCallback.strFileName = pSegment->szFileName;<br />
hStatusCallback.strFilePath = pSegment->szFileName;<br />
hStatusCallback.strUrl = pSegment->szURL;<br />
<br />
HINTERNET hSession = InternetOpen("Agent",<br />
INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, INTERNET_FLAG_ASYNC);<br />
InternetSetStatusCallback( hSession,<br />
(INTERNET_STATUS_CALLBACK)InternetCallbackFunc );<br />
HINTERNET hInetFile = InternetOpenUrl( hSession, CString(szURL,<br />
strlen(szURL)), NULL, 0, <br />
INTERNET_FLAG_RELOAD | INTERNET_FLAG_PRAGMA_NOCACHE | <br />
INTERNET_FLAG_NO_CACHE_WRITE, (LPARAM)&hStatusCallback );<br />
if(hInetFile == NULL && GetLastError() == ERROR_IO_PENDING) {<br />
if(WaitForSingleObject(hErrorEvent, INFINITE) == WAIT_OBJECT_0) {<br />
ResetEvent(hErrorEvent);<br />
hInetFile = hStatusCallback.hInetFile;<br />
MessageBox(NULL, "Got handle", "info", MB_OK);<br />
}else<br />
MessageBox(NULL, "Error during waiting for the Error event!", "ERROR",<br />
MB_OK | MB_ICONERROR);<br />
}
|
|
|
|
|
Ok, first post here.
I have been looking over the articles, which are great. Some seem to go into so much depth I become overwhelmed.
Right now, I am working for a company who has purchased a very poor piece of software to automate things. The program was created in visual basic, and is just about worthless.
One thing that we need is to be able to format the output from its report program, for printing our invoices etc. Since the company who made the program that we are using refuses to add in the hookings for plugin support, I am writing an external program do do what we need.
What I need to do is, monitor the program to see when it opens an instance of the reporter program, because the text that is displayed in the reporter is saved onto the hard disk in the form of a text file on our main server. I need to then open the text file, format it and print it. The latter parts are no issue for me, I am just kinda overwhelmed right now thinking of the proper way to watch the program and watch for the creation of that window. I do not want to tax the system at all, and I would think that I could do it without having any visible impact on performance.
HELP!
Thanks
Tim Reynolds
razialx
|
|
|
|
|
|
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?
|
|
|
|
|