|
I've been trying to do this for longer than I care to admit and every implimentation I try reactivates the last window that was active, even if my mouse is a long way away from it, over another view entirely.
Please help, or alternatively please send me a nice long piece of rope, and instructions on how to tie a noose.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
Try this:
1) Create a base view class that all ytour other views derive from.
2) Create a member variable of type CRect (we'll call it m_windowRect)
2) Override OnSize()
3) In the OnSize() function, insert the following code:
GetWindowRect(&m_windowRect);
ClientToScreen(&m_windowRect);
4) Override the OnMouseMove() function
5) In the OnMouseMove() function, insert the following code:
if (GetFocus() != this)
{
ClientToScreen(&point);
if (m_windowRect.PtInRect(point)
{
SetFocus();
}
}
I havn't tried any of this myself, but it should work with minimal tweaking.
|
|
|
|
|
Thanks, but I've tried it and apart from keeping the rect as a member variable, it's pretty much where I started out, and the same problem is evident - the last view highlighted activates instead of the one the mouse is over. I've gone so far as to iterate through all my views and grab their positions, but no matter what I do, the last view highlighted gets activated...
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
Have you tried using WindowFromPoint() ?
Neville Franks, Author of ED for Windows
http://www.getsoft.com
|
|
|
|
|
I love you, and I want to bear your children.....
I spent half a day searching the MSDN for this API function - thanks, I'll give it a try.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
OK.. I am drawing a graph in my view and then want to save the point array in my document. Problem arises when i serialise.. During run, when I try to save it, he save window comes up fine.. but the graph is erased when my view is redrawn after closing the save dialog box. I did put invalidateRect in my OnDraw function .. but didn't work!!
I also added a call to UpdateAllWindows in the overriden Serialize function for my CDocument.. but still does not work!!!
also, anyone knows how to obtain a pointer to the current view from CDocument??
It is what we choose to be that makes us what we are, far more than our abilities.
-J.K. Rowling
|
|
|
|
|
To get a pointer to the View from your document:
CFrameWnd *pFrameWnd = (CFrameWnd *)AfxGetMainWnd();
ASSERT (pFrameWnd != NULL && pFrameWnd->IsKindOf(RUNTIME_CLASS(CMDIFrameWnd)));
pFrameWnd = ((CMDIFrameWnd *)pFrameWnd)->GetActiveFrame();
CMyView * pView = (CMyView*)pFrameWnd->GetActiveView();
This is a generic method - it works from anywhere, but only works if your document is attached to the active view.
Your other problem is a mystery to me. Could you post some code to show what you're doing ?
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
How can I in get MX Records from DNS when I know only hostname or ip of main server?
Please Reply to my email:piopawlu@interia.pl
Piotr Pawluczuk
|
|
|
|
|
Does anyone know how to use DeviceIoControl()??? I read the document from microsoft and MSDN...but still don't know how to use it.....can anyone give me a small tutorial about this function?
Thanks
|
|
|
|
|
Hi All,
I'm beginner in VC++ and I have VC++ 6.0. I have this problem now.
How I create user items in system menu of my applications ?
Thanks,
Libor
Libor Matejka
|
|
|
|
|
Please explain ? If you want to add items to the menus, use the resource editor to create items and then Class Wizard to create functions linked to the item ID's. If that is not what you mean, please re-state the question.
Christian
#include "std_disclaimer.h"
People who love sausage and respect the law should never watch either one being made.
The things that come to those who wait are usually the things left by those who got there first.
|
|
|
|
|
Thank you for your answer, but I mean SYSTEM menu. This is menu under Application icon in caption bar of application.
Libor Matejka
|
|
|
|
|
Create a sample Dialog based application, then look at the implementation of the OnInitDialog member function. In here you will see how the About Box menu option is added to the System Menu. From this you should be able to add almost anything you like to the System Menu.
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
|
|
|
|
|
Thank you,
this is very simle and fast
Libor Matejka
|
|
|
|
|
I send when I click on a static text (CLabel) a message to my main app that I intercept with the OnNotify() routine.
(I don't have the listing right now this explain the aproximate syntax sorry bout this)
But I noticed annoying long delay (1 second) before I can re click on the static
should I return 0; once I get the message ?
For now I alway return to the normal OnNotify procedure
Onnotify( wparam, lparam ...)
{
switch(proc)
{
case:
some code;
return 0; <---For now I just have a "BREAK;" here
}
return Onnotify();
}
Many thanks
|
|
|
|
|
I have declared a function called solve like this :
double Solve(double (pFn) (double), double pX);
Now I don't know how to use this function with for example pFn = 2*X-1...
the following code doesn't work :
lSoluce = Solve( (2*X-1) (X), X) ????
Thank in advance for your help.
Leo
|
|
|
|
|
Hi !
if pFn - is a pointer to a function that date a double and returns double your code should be change into:
iSoluce = Solve(pFn, X);
Best regards,
-----------
Igor Soukhov (Brainbench/Tekmetrics ID:50759)
igor@soukhov.com | ICQ:57404554 | http://soukhov.com
|
|
|
|
|
2*X-1 is a statement not a function. A function would be something like sqrt(). The documentation for qsort() usually has a good example of function passing.
|
|
|
|
|
Hi,
I wrote a DLL with an exported class containing a template method.
When using this DLL, I got a linker error on this method.
How to correct this in VC++ ?
Thanks a lot
Nicolas
|
|
|
|
|
I am trying to generate a continuous tone at a desired frequency. I cannot use Beep() because once the tone begins, I need to do other processing. I need it to continue until I stop it from elsewhere in my code or send another frequency. Beep() does not return until the specified duration has elapsed. Any suggestions? I have looked at PlaySound and Direct Sound, but these appear to be much more complicated solutions than should be required to play one tone.
Thanks.
|
|
|
|
|
Windows has no APIs for generating a continuous tone.
If you only need one frequency, or at most a small set of frequencies, you should probably create .wav files and use PlaySound to play the specific file you need, with looping turned on. If you need arbitrary frequencies, you're getting into hairier territory.
|
|
|
|
|
I know this is not a nice solution, but it works...
Start another thread that calls Beep(), when you need to stop the tone, just kill the thread, and eventually start it again with another frequency...
something like:
DWORD WINAPI WorkThread(LPVOID lpParameter)
{
Beep(500, 1000000);
return 0;
}
int main(int argc, char* argv[])
{
DWORD dwThreadId, dwThrdParam;
HANDLE hThread;
dwThrdParam = 1;
hThread = CreateThread(NULL, 0, WorkThread, &dwThrdParam, 0, &dwThreadId);
Sleep(1000);
CloseHandle(hThread);
return 0;
}
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
I have a question regarding the ADO Data Controls that Microsoft provides with C++ ( i.e. Adodc, DataCombo, DataGrid, DataList, DataRepeater) It seems that these controls were primarily designed for use in VB. However, I am a cheap C++ programmer and wish to include these tools in an application that I am building. The problem I am experiencing arises when I attempt to bind DataCombo and DataList and run time, as the interfaces for the controls don't exposes any methods/properties to assign the DataSource and the DataField. They only provide the methods/properties to assign the RowSource and ListField. I know the methods/properties exist cause VB shows them and the VC++ dialog editor shows them too. I also tried to just statically bind them, however it seems they lose their binding at run time. Where do the DataSource and DataField properties disappear too, or where do they come from? Why do the controls lose their binding at run time if I statically bind them in the dialog editor? Are these two problems related? I attempted to solve this problem myself however, documentation on using these controls in C++ is scarce. Any help would be greatly appreciated.
Luke Stamm
luke@win-world.com
Wholesale Information Network, Inc.
|
|
|
|
|
Writing a short routine which opens a file I noticed the following:
try {
CFile file;
file.Open(filename, CFile::modeRead);
file.Read(buffer, file.GetLength());
file.Close()
}
This will not throw an exception if the file does not exist.
A slight change:
try {
CFile file(filename, CFile::modeRead);
file.Read(buffer, file.GetLength());
file.Close()
}
This code will throw an exception if the file is missing.
It must just be a misunderstanding on my part about the purpose
of exceptions/handlers, but could someone explain it?
|
|
|
|
|
CFile::CFile() must throw an exception because it does not return a value.
CFile::Open() does not throw an exception because its return value and CFileException *pError parameter can be used to handle any unsuccessful calls.
|
|
|
|