|
what do you mean about "key press missing"? can not detect chars or keys in WM_CHAR or WM_KEYDOWN? if so, use PreTranslateMessage(), MFC dialog blocks some key events - I don't know why MFC does this.
|
|
|
|
|
includeh10 wrote: what do you mean about "key press missing"?
No characters appearing in the edit field when we type something in the keyboard. My PreTranslateMessage() filters out only the ESCand ENTER characters in my app.
Thank you
Deepak
|
|
|
|
|
Hi All,
I am using a software to run a occupancy report manually by clicking a button in the software.
I would like to automate this task by writing MFC application to programatically click the button every hour. So I dont know how to activate other application's button by my program.
Could anyone please suggest me some possible solution for this?
I am not sure where to start and how to proceed. Any piece of information will help me a lot.
Thanks in advance.
Regards,
Ram
|
|
|
|
|
Ram Murali wrote: So I dont know how to activate other application's button by my program.
Why not just use a timer in the main application so it sleeps for an hour and then runs its activities? Alternatively you could probably use the Windows Task Scheduler.
|
|
|
|
|
Hi Thanx for your reply.
Timer function wise, i have no problem.
But my problem is how to activate other application's button using my own program.
I used FindWindow() method to get the other application's window handle.
But How to get the control of the button to send message to that button?
This is the biggest issue to me now.
Regards,
Ram
|
|
|
|
|
Ram Murali wrote: But How to get the control of the button to send message to that button?
I think you need to enumerate all the child windows until you find the button, then post a message to the button's HWND. However this seems a very complicated way of going about solving what is really a simple timer issue.
|
|
|
|
|
Can you please tell me the easiest way to do this?
Thanks
Regards,
Ram
|
|
|
|
|
Richard MacCutchan wrote: Why not just use a timer in the main application so it sleeps for an hour and then runs its activities?
I think it's a 3rd-party application that he's wanting to run and simulate a button click within.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Use FindWindow() and then EnumChildWindows() to find that button .Refer MSDN for both functions.That will surely help u. Mark this ans as good if u feel it helped.
Kushagra
|
|
|
|
|
okay let me give you a simpler example to explain what isnt working for me...in the following code, this is the output I get :
$ ./a.exe
Enter 10 numbers: 1 2 3 4 5 6 7 8 9 10
The biggest number right now is:1
The biggest number right now is:2
The biggest number right now is:3
The biggest number right now is:4
The biggest number right now is:5
The biggest number right now is:6
The biggest number right now is:7
The biggest number right now is:8
The biggest number right now is:9
The biggest number right now is:2281060
The real biggest number is: 2281060
THE OUTPUT I WANT IS:
Enter 10 numbers: 1 2 3 4 5 6 7 8 9 10
The biggest number right now is:1
The biggest number right now is:2
The biggest number right now is:3
The biggest number right now is:4
The biggest number right now is:5
The biggest number right now is:6
The biggest number right now is:7
The biggest number right now is:8
The biggest number right now is:9
The Real biggest number is: 10
what am i doing wrong?
#include <iostream>
#include <cmath>
using namespace std;
int main ()
{
int count, biggest = 0;
int numbers[10];
cout << "Enter 10 numbers: ";
for (int i = 0; i < 9; i++)
{
count++;
cin >> numbers[i];
}
for (int r = 0; r < count; r++)
{
if (numbers[r] > numbers[r-1])
{
biggest = numbers[r];
cout << "The biggest number right now is:" << biggest << endl;
}
}
cout << "The real biggest number is: " << biggest;
return 0;
}
|
|
|
|
|
for (int i = 0; i < 10; i++)
|
|
|
|
|
HI! i ddon' know much about c++
i had this dll using vb6 inject into another process winsock2
for tunnel. my problem is that i had the dll injected but i need a function to make dll pass host and port they going to connect into vb6 maybe like call back here is the function in dll
int WSAAPI myconnect(SOCKET s, struct sockaddr *name, int *namelen)
#define SIN(name) ((struct sockaddr_in *)(name))
{
struct sockaddr_in *paddr =(struct sockaddr_in *)name;
char *ip =inet_ntoa(SIN(name)->sin_addr);
int port =ntohs(paddr->sin_port);
return ((Pconnect)hookconnect.pTrampoline)(s, name, namelen);
}
thank you much
if you need i can send u dll source.
|
|
|
|
|
Hi,
I am working on a MFC Tabbed dialog project for a handheld tough book. One of the tabs needs to show a PDF doccument. I am using Adobe PDF viewer to do this.
Everything looks fine except the scrolling issue.
When i use the Application Dialog scroll bar to scroll the PDF Viewer dosent refresh properly.
I shared the image at the following location.
http://picasaweb.google.com/kkraju.vc/Desktop#5401117149728341778[^][^]
If anyone faced this kind of situation please give me some inputs.
Thanks,
kkraju
|
|
|
|
|
the only thing I can think of is adding a message handler for WM_VSCROLL in your application, and then (possibly when the scrolling has stopped) send a 'refresh' to the Adobe PDF Viewer (not knowing the Adobe PDF Viewer API)
'g'
|
|
|
|
|
Thanks for the input, i will give it a try.
|
|
|
|
|
I have been trying to correct an assertion failure in an MFC app for the last few days. It's been really fun... while the rest of you have been doing boring things like riding your outlandish motorcycles or bar-hopping with your chubby girlfriends, I get to really spend some quality time trying to comprehend things like "___Afx_4_U_T_q_HowDoesThisEvenCompile_<t>".
Anyhoo... an assertion fails somewhere in Wincore.cpp (a local called pMap comes up as 0, implying a call from the wrong thread, I am thinking). When the failure occurs, Visual Studio breaks into Wincore.cpp (which it finds and opens) and does a good job of debugging. It shows a call stack, "Watch" and "Quickwatch" seem to work, etc.
The problem arises when I try to do some manual editing to Wincore.cpp, or even just set a breakpoint in Wincore.cpp. It quickly becomes obvious that even though Visual Studio itself found and opened this file just a moment ago, it is not actually using the copy of Wincore.cpp that I am seeing as part of the build process. So, I can make garbage edits to it, do a "Rebuild All," and still get no errors. This seems completely wrong to me and provokes my ire at a very fundamental level. I mean, I guess Microsoft and I have different definitions of terms like "compile" and "source code."
When I try to simply set a breakpoint in Wincore.cpp without changing it, the breakpoint's red dot indicator goes "hollow" at runtime. When I hover over the breakpoint, Visual Studio tells me that the source code is different from that used in compilation. If I check "allow location to be different" in the breakpoint properties, then the breakpoint gets hit, but Visual Studio claims to have no source code. It prompts me to browse to the original source code. Strangely, there is a text field in this dialog showing where the source code originally resided, and this is some path on F:-drive (which, in my case, is a removable flash drive that isn't even present in the system).
I'm not sure how much more "original" I can get than the file I'm TRYING to use, which is in a subfolder of C:\Program Files\Microsoft Visual Studio 2008\ and was opened up for me by Visual Studio. Am I expected to e-mail Raymond Chen for the copy on his hard drive perhaps?
Generally, I don't need to edit Wincore.cpp; I would never do this permanently. Also, I suppose I haven't had much experience setting breakpoints in that file. However, I think that what I am trying to do should be possible, and I think that Visual Studio's behavior is very misleading. Am I or am I not building a file called Wincore.cpp into my project? The IDE really seems to want to have it both ways.
Perhaps I simply have something configured wrong?
Are "precompiled headers" causing the problem? (I don't think so, since Wincore.cpp is not really a "header" file; BUT, in my miserable experience with Visual C++, "precompiled headers" are one of Microsoft's most popular implements of torture. )
Also, if anyone has some different advice about how I ought to find the problem, that's very welcome too. I don't give a flip about Wincore.cpp or understanding it. I just want to fix my problem.
|
|
|
|
|
I see you're using VS 2008.
I know that when an MFC application initialises, the function AfxGetThread() in thrdcore.cpp will be called. I was able to set a breakpoint on that function, without even opening the file. I chose Debug->New BreakPoint->Break at function-> enter function name as AfxGetThread() and set line and character as 1 each.
When I hit F5, the debugger opened thrdcore.cpp and broke at the beginning of AfxGetThread() . You might want to try it with the function of your interest located in wincore.cpp . The IDE will open the correct file (that it is using), and break at the location of your interest.
You might as well consider using "Advanced breakpoints" (just do a search).
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Member 3680785 wrote: It quickly becomes obvious that even though Visual Studio itself found and opened this file just a moment ago, it is not actually using the copy of Wincore.cpp that I am seeing as part of the build process. So, I can make garbage edits to it, do a "Rebuild All," and still get no errors. This seems completely wrong to me and provokes my ire at a very fundamental level. I mean, I guess Microsoft and I have different definitions of terms like "compile" and "source code."
I think that wincore.cpp is provided for debugging purposes only, MFC can't be compiled easily from the source. What your app links to is the debug versions of MFC dlls. As for VS finding the source that's probably because it is referenced in the dll or some pch file or some such.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
|
I've recently moved my data base code into a worker thread, which works just fine unless the data base open fails. I currently have the thread wait 15 seconds, and then try the open again. This process repeats until the data base opens successfully or the application exits. The problem I'm having is that, when this logic is occurring, my UI thread will fail with an access violation some time later. It appears that having the CDatabase::OpenEx() call fail causes some sort of corruption to either the UI thread's MFC state or its stack, which is then exposed as the UI is navigated.
I'm using SQL Server 2005 Express, Service Pack 2.
I've tried the following to resolve this:
1. If I comment out the data base operations (OpenEx() ... Close() ), the UI does not crash.
2. If I comment out the data base operations like in #1, and replace them with a AfxThrowDBException(...) , the UI does not crash.
3. One suspect was the CDatabase::OpenEx() implementation, which does some hinky looking things trying to find a window handle. I overrode it and passed a NULL window handle to the ::SQLDriverConnect() call that does the real work of connecting to the data base. The UI still crashes.
From these results I can only conclude that there is some kind of problem here using CDatabase /CRecordset in a worker thread that isn't documented. I've searched on MSDN and Google'd several times, and only found claims of issues with specific ODBC drivers.
Anyone have any suggestions, or ideas that I've missed?
Software Zen: delete this;
|
|
|
|
|
Hi Gary,
Are your CDatabase functions inside your application executable or are you calling them from a helper DLL? Are you static or dynamic linking?
Does the error occur if you add the following before attempting to use CDatabase::OpenEx:
AFX_MANAGE_STATE(AfxGetStaticModuleState());[^]
Best Wishes,
-David Delaune
|
|
|
|
|
The CDatabase functions are inside my application executable, and MFC is dynamically linked.
I tried using your AFX_MANAGE_STATE() suggestion, but it had no effect.
Thanks for the help .
Software Zen: delete this;
|
|
|
|
|
Hi,
Apologies if this has been covered somewhere but I've not found anything related. I'm working on an idea which would require a long-running task to complete at the time the user logs off, I know it's possible to delay the logoff but I was hoping to find a way to run the task as part of the logoff, something like when Windows synchronises offline folders (not sure if that's exactly the right term as I am working from memory here).
Does anyone have any ideas?
Thanks
|
|
|
|
|
|
*click*
Good Answer.
“Follow your bliss.” – Joseph Campbell
|
|
|
|