|
You're better off keeping a class member variable specifying which bitmap is currently displayed, as GetBitmap() may not necessarily return the same handle that you give it, although it probably will.
Also, you're comparing against hBmp1 in OnButton1() , but in OnInitDialog() , hBmp1 is a local variable. There must be another definition somewhere that is causing the code to work unexpectedly.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
When I attempt to create a MSFlexGrid within OnCreate(...) of my derived COleControl I get a memory access violation. (Compiles Find)
This is what I tried:
CMSFlexGrid m_MyGrid; //In Header
m_MyGrid.Create(NULL, "Grid", WS_VISIBLE, CRect(0,0, 400,300), this, IDC_GRID_MAIN); //In OnCreate(...)
Thanks.
|
|
|
|
|
I have an application where using a timer I periodically check to see if a client is trying to connect over a socket to a server...the server code uses the Accept() call to accept new clients, but I dont want the call to Accept() to block if no one is attempting to connect. I want to immediately execute some other code. Can I make it non blocking??
Thanks.
Jerry
|
|
|
|
|
I think you may instead want to call Listen() in a separate thread. Listen() is a blocking call (I believe you can specify a timeout) that waits for a client to connect. Accept() is called when the connection is accepted.
See this[^] MSDN link.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Ravi Bhavnani wrote:
Listen() is a blocking call (I believe you can specify a timeout) that waits for a client to connect. Accept() is called when the connection is accepted.
Actually, Listen() simply sets up the socket for accepting connections, and accepts the size of the connection backlog (how many connections can be queued before they are accepted using Accept() ). Accept() is a blocking call that waits for a connection, and accepts it when one arrives.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
|
I think you should go by select() then. It takes a parameter which specifies a timeout for the operation. You can also check out the WSAAccept() function.
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
|
|
|
|
|
For anyone learning Windows Sockets development:
http://www.sockets.com/[^]
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
or if you don't worry about win9x stuff, you can look here around for some articles about IOCP.
|
|
|
|
|
I've been programming in MFC for some time now, but have not needed to do much with the "control bar" classes until recently.
My problem is, I would like to have a control bar (toolbar, rebar, dialogbar, i-don't-care-which-bar) with a combobox whose contents is added at runtime (from a database, for example).
I've coded up a toolbar that draws a combobox overtop a seperator, but that's very klunky. I tried using a dialog bar, but since its not CDialog derived, one cannot easially add a control instance to one's app and initialize the combobox in the traditional manner. And of course, a rebar seems only to take a toolbar, dialogbar, or (I think) individual controls, but I want multiple controls on a bar/band.
It seems the the controlbar functionality is made more for sending simple messages to one's app, rather than manipulating more complex data. Is there are a simple solution to this problem that I'm overlooking? Thanks for your help.
-Jesse
|
|
|
|
|
I have a windows application that made by someelse. I don't have the source to change it. It takes kb/mouse inputs and does some work. Therefore, I wish I could use a program to pretend the kb/mouse sending inputs to it, so that it could running automatically.
If the target application is running foreground, everything could be easy. Using any keyboard/mouse record & play software will satisfy me. But I wish it could be running background. So I can use forground (another active windows) to do something else, for example monitor.
So, the problem is how to pretend kb/mouse and send message to a BACKGROUND app. For example, how to send "hello" to a un-active Notepad and let Notepad accpet "hello" as keyboard inputs.
I tried PostMessage to it directly. But it seems it will not response to my message. (I used another little program to prove that all these KeyUP and KeyDown messages are sent correctly). So I think there is some windows mechanism which makes un-active windows response to kb message.
I have no clue at all, any advise is very welcome.
Thanks,
Joe
|
|
|
|
|
Hey i am using CSocket class in MFC.
My program(client) should connect to multiple servers.
I am using single port at client to connect.It's connecting to the first server
successfully.For second server while connecting it's failing.
The error code it's returning is 0x00002748.
What's the meaning of this error code.
Is it possible to connect from the same port to multiple servers.If possible
pls help me.Is there any problem with CSocket class??
Thanks
|
|
|
|
|
Sivaji wrote:
What's the meaning of this error code.
"A connect request was made on an already connected socket."
For anyone learning Windows Sockets development.
http://www.sockets.com/[^]
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
In my project, I need to automate the process of creating a new "incoming" network connection which acts as a server for client connections. We can manually go through this process: "Control Panel" -> "Network Connection" -> "create a new connection" -> Click "next" on the "new connection wizard" dialog -> Choose "set up an advanced connection" -> "connect to another computer" -> choose "Host" ... We can assume that user always select the fixed choice at each step.
Is there scripting tools or Windows API which can automate the above process? Anyboby can give me some hints? Thanks a lot,
-Jeff
|
|
|
|
|
I am sure that all the wizard does is set up registry entries. The trick is to figure out which entries, and set them yourself.
I am sorry, but I do not know what the entries are.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
Hi,
i need to find out the amount of processor time used by a process.
My Requirement:
i am running 2 programs.
1) The ACTUAL process.
2) a monitor process.
The ACTUAL process goes into an infinite while
loop. it begins to use a 99% of the CPU time.
i need to detect this condition from the monitor
program and kill the ACTUAL program.
please help, its very urgent.
thank you..
|
|
|
|
|
Just to add my 2 cents, this sounds like a very BAD solution. You need to figure out what is causing the infinite loop in the first place, and fix it! Doing it your way could cause other problems - resource leaks, for instance, or leave files/data in an unknown state.
An expert is somebody who learns more and more about less and less, until he knows absolutely everything about nothing.
|
|
|
|
|
dear navin,
i gave an example....
suppose... a program enters into an infinite
loop... (suppose)...
then, it would surely use the maximum CPU time.
there's is a method by which we can detect the
cpu usage time of a process. i've seen the
method somewhere, but i dont remember it now..
can you help me.... ??
bye
|
|
|
|
|
Using the majority of the CPU (e.g., 95%) and an infinite loop are not necessarily the same thing. While an infinite loop does cause the CPU usage to go very high, other operations can also cause the CPU usage to spike. So, if you were simply terminating a process based solely on CPU usage, you may be doing so for the wrong reason. Make sense?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I agree with Navin. Address the infinite loop issue and the need for a separate "monitor" process should go away. Even if you do need an infinite loop (e.g., while (1) ), you should still take measures so that it does not consume all of the CPU.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I agree with other two statements.
you want to do an ugly thing
but look for a class from Paul Maker on CP
CPdhQuery
I think this can solve your problem.
|
|
|
|
|
Hi,
I have dialog based application. If my event handler is in any class other than the main dialog class it never gets called. I would like to move the event handler to my subclass of a control.
Suggestions? What am I doing wrong?
Thanks
Hua-Ying
|
|
|
|
|
some example code so that we can see what happen? I'm not a wizard
Jaime
|
|
|
|
|
Example code probably won't help but I can walk through the steps to reproduce the problem.
I'm using Visual Studio 2003 .Net
- Create new MFC Application, select application type Dialog based.
- In the class view, using the wizard create a new class with a base class of CButton, I called mine MyButton.
- in the main dialog create a new button, right click and "Add Event Handler" choose the Message type: BN_CLICKED and the class as MyButton.
- in the handler OnBnClickedButton1 add MessageBox("hello");
- run application
- click button, nothing happens
however if you added the Event Handler to the main dialog class created by the wizard, then everything works fine.
Ideas?
Thanks
Hua-Ying
|
|
|
|
|
did you put a break point in your handler ?
me think it's the MessageBox that simply doesn't show.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|