|
Now I'm coming to what I wanted. So the GWL_USERDATA contains this (the pointer to the class instance) and that I can call it back (Ah, now I understand why they called it CALLBACK ) via the obj, and obj is still the same pointer to the address of the class instance: this I guess?
LPCSTR Dutch = "Double Dutch "
|
|
|
|
|
SetWindowLong(this->somewhere, GWL_WNDPROC, (LONG)SubClassProc); I guess you meant this to read
SetWindowLong(this->somewhere, GWL_WNDPROC, (LONG)WndProc); Otherwise, I'm not catching your question.
I think this thread addreses your problem.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I wasn't really clear about what I wanted, but I'm not using MFC or WTL, so I think that has to clear bit's up. the HWND somewhere I declared is just an existing working HWND, but I just had to take a name.
The SubClassProc is indeed a failure, it has to bee WndProc instead.
LPCSTR Dutch = "Double Dutch "
|
|
|
|
|
Maybe you haven't noticed my previous post contained a link to another discussion where a solution is provided (In my browser the link appears almost unnoticeable.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I am having problems with running this code twice..
I have a function that calls OnStartThread() after the thread has finished the work and the data has been updated I try to run this again and my program crashes. I think it has to do with the PostMessage (not sure though).. do I have to kill the msg after I post it? What am I doing wrong?
......
void run();
void OnStartThread();
volatile BOOL running;
static UINT run(LPVOID p);
......
void CMainFrame::OnStartThread()
{
running = TRUE;
UpdateData(FALSE);
AfxBeginThread(run, this);
}
UINT CMainFrame::run(LPVOID p)
{
CMainFrame * me = (CMainFrame *)p;
me->run();
return 0;
}
void CMainFrame::run()
{
.....
PostMessage(ID_UPDATE_TIME,0,0);
running = FALSE;
}
Thanks,
Rob
|
|
|
|
|
You are not doing it in thread. You sure have to use PostMessage to start a function in another thread. Look, CMainFrame belongs to one thread and when you are calling a function of it from another, the function is still running in same thread and context as CMainFrame
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
Need Web-based database administrator? You already have it!
|
|
|
|
|
I'm not sure I fully understand.. If I start the worker thread from CMainFrame and I want to call a function inside CMainFrame I shouldn't use PostMessage? When I try to run the function with out posting the msg. it crashes because the function that gets called assigns and accesses a pointer to CListView..
The PostMessage seems to work only once.. If I try to run the worker thread again the app crashes at PostMessage?
Can you give me some more details so I can understand what I am doing wrong?
Thanks!
Rob
|
|
|
|
|
Omg... now I'm confused, lol. I saw that you have 2 functions with same name, one is static and one is not. But this is doesn't matter, you should not use pointer to CMainFrame in another thread to un functions, you should use PostMessage always to communicate between threads, then in the handler of that message (in CMainFrame) you can call any function of the frame.
So it goes like this:
CMainFrame (thread 1) -> [New thread] -> PostMessage to CMainFrame (thread 2) -> Handle message in CMainFrame (thread 1) -> call to run (thread 1)
You see? There is no direct access to CMainFrame functions from thread 2. Instead you are posting message, and it works like trigger, command to CMainFrame to start working with run
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
Need Web-based database administrator? You already have it!
|
|
|
|
|
so with in run(LPVOID p) instead of passing a pointer to CMainFrame and executing run() I should PostMessage to CMainFrame to run the run()? Then with in run() I can post a msg back to CMainFrame to run the UpdateTime() function?
hehe how weird..
|
|
|
|
|
Errr.... lol, well it is because you have function names that are not suitable for such communication
But yes, this is the preffered way. Of course you can use Events, mutexes, semaphores and another such tricks, but PostMessage is the easiest one. The point is that you can't use a pointer (class, whatever) from another thread to run functions from the second
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
Need Web-based database administrator? You already have it!
|
|
|
|
|
Ah, well, discard my previos post. I just paid attention that your "run" function is static, which has same meaning as global. So you should not use the pointer to CMainFrame to reach it, but: CMainFrame::run()
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
Need Web-based database administrator? You already have it!
|
|
|
|
|
Does anyone know of a line drawing function where I can specify the degrees the line should be drawn (i.e. - 0 to 360 degrees). I am also looking for a function to export this line as an image and save it to a file. Any help would be great. Thanks.
Nick Parker
Actually, real programmers don't need the enter key- they just type in 00001101."
|
|
|
|
|
I believe you should be able to use just sine and cosine calculations to figure this out and use LineTo etc to draw the lines.
|
|
|
|
|
Is it the same way you do when exporting functions from a DLL when exporting a function from an EXE??
Rickard Andersson@Suza Computing
ICQ#: 50302279 (Add me!)
E-mail: nikado@pc.nu
I'm from the winter country SWEDEN!
|
|
|
|
|
As I remember it is the same way. And same way you are exporting them. I did such thing about 2 years ago, using DEF file ,not __declspec . So not sure if you can export/import classes in exe. But LoadLibrary and all that stuff is working fine
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
Need Web-based database administrator? You already have it!
|
|
|
|
|
Philip Patrick wrote:
So not sure if you can export/import classes in exe
But I can export functions as you said!
Thanks!
ps. this is my 400th message!
Rickard Andersson@Suza Computing
ICQ#: 50302279 (Add me!)
E-mail: nikado@pc.nu
I'm from the winter country SWEDEN!
|
|
|
|
|
Rickard Andersson wrote:
this is my 400th message!
Congratulations!
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
Need Web-based database administrator? You already have it!
|
|
|
|
|
congrats
|
|
|
|
|
How can I make my app check if there is any current transfer??
I mean, if the internet connection is on and nobody is sitting and surfing I want the modem to disconnect. But how will I know if there is any transfer?
I hope you understand me!! Please ask me if you don't!
Rickard Andersson@Suza Computing
ICQ#: 50302279 (Add me!)
E-mail: nikado@pc.nu
I'm from the winter country SWEDEN!
|
|
|
|
|
Isn't there already a "Disconnect timeout" in some of the RAS dialogs? If you can't find it, surely your modem has this ability. Read up on it's AT command set.
|
|
|
|
|
Mike Nordell wrote:
Disconnect timeout
ooh.. I will check that out!
Thank you!
Mike Nordell wrote:
surely your modem has this abil
But how do I put my modem in to the Visual Studio IDE!?!?!!?
Rickard Andersson@Suza Computing
ICQ#: 50302279 (Add me!)
E-mail: nikado@pc.nu
I'm from the winter country SWEDEN!
|
|
|
|
|
But how do I put my modem in to the Visual Studio IDE!?!?!!?
That is of course completely impossible, but it does display you want to set the timeout programmatically.
The easiest way I can come to think of is to open the com port the modem is connected to and send it the "set timeout" AT command (it might be ATS3, but don't take my word for it since it's over ten years since I last played with it - insetad do that read-up on your modems AT command set).
|
|
|
|
|
I think u can't.
One solution (of many) I use on Linux, don't know if it works on Windows: Don't requery or perform internet access to often in your application, let a timeout a chance to happen and terminate then internet access. Then you can check in your application if there is still internet access, and only if there is make access to the internet. LAN access is always fine though.
Some PCs can't check on there own if they are online: The inet access is via a router (instead of a local ISP connection), so it gets hard. For that case I gave my application a command line option to trigger online/offline... but well, the user has to trigger that on his own. Well, users are stupid, let teh sysadmins do the work...
Some emailchecker or messanger might cause high internet costs still, because ´the computer is online endless....
|
|
|
|
|
Is there a way to block all internet acces on a computer??
Rickard Andersson@Suza Computing
ICQ#: 50302279 (Add me!)
E-mail: nikado@pc.nu
I'm from the winter country SWEDEN!
|
|
|
|
|
do you mean write a program that when its running it blocks all access? wouldn't it be easier to just put permissions on the proxy to keep certain users from accessing the net?
-dz
|
|
|
|