|
42....well someone had to do it.
|
|
|
|
|
Hi all
i m using GotoDlgCtrl for set focus on button control in dialog box.becoz setfocus function not working on button control.
but GotoDlgCtrl is not working in form view.
so please tell me what can i use for setfocus on button control in formview.
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
If this is MFC, a formview is just a wrapper around a modeless dialog box.
So, rather than setfocus...
WM_NEXTDLGCTL
This message performs additional dialog box management operations beyond those performed by the SetFocus function WM_NEXTDLGCTL updates the default pushbutton border, sets the default control identifier, and automatically selects the text of an edit control (if the target window is an edit control).
Hope that helps!
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Thanks sir its done now.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
modified on Friday, February 27, 2009 7:22 AM
|
|
|
|
|
If you have used DDX_Control on the formview item you can do:
m_controlVariable.SetFocus()
if not, you can use
GetDlgItem(IDC_CONTROL_ID)->SetFocus();
If you vote me down, my score will only get lower
|
|
|
|
|
not sir its not working.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
hi...
i am new to serial port programmming...my problem is as folloes...
i have to write a command to a plc connected to my serial port of windows os and then read the data from the same serial port.both read and writre take place continously for every one minute..how do i go about doing this...i am programing using c..also do i need to use threaads??
is there any code available for this??
|
|
|
|
|
rao_abhilash wrote: also do i need to use threaads??
Probably.
rao_abhilash wrote: is there any code available for this??
Yes, free code at my magic site www.cpallini.free.serialport.threadz.codez.com.
Or you may try the CP article search engine [^].
BTW: Have you read forum guidelines [^]?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
In addition to codeproject, the following web page explains a lot of the problems / misconceptions / solutions to working with serial ports.
http://www.flounder.com/serial.htm[^]
Very well worth a read, even if I don't follow everything he says like gospel.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
rao_abhilash wrote: do i need to use threaads??
No, so long as you don't mind your application not responding to any input while the serial IO is occurring. If it's a console application, then that is probably fine.
rao_abhilash wrote: how do i go about doing this
The general procedure is this:
- Create a handle to the port with
CreateFile - Set the port parameters with
SetCommState - Send data to your plc with
WriteFile - Get data sent by your plc with
ReadFile - When you're done, close the port handle
Really, it's as simple as that if you ignore things like asynchronous IO etc.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
The PLC manual will tell you:
What start and stops codes to use before and after the body of the messages. Possibly something like no start-code and a stop code of CR LF after the message, though the PLC programmer may have changed it to use custom start and stop codes.
The PLC manual will also give you the default baud rate, parity and so on to set your PC port up to.
I'd definitely recommend using a port monitor tool such as PortMon on the PC to see what's really being transmitted and Received (as opposed to what you think should be).
I've had a PC communicating with an Omron PLC and my biggest headache w as having to relearn the PLC's ladder logic!
|
|
|
|
|
thnk everybody for ur kind suggestion....how ever i have done serial programming before werin i transferred around 30 bytes of binary data to and fro between windows and linux machine...it was succesfull... my question now is when i have to read and write data alternatly one at a time using same serial port, does the initailaiztion or tyhe code change??.. if yes what changes are to be done..??
|
|
|
|
|
One port both covers reading and writing which, though there are ways of squeezing out extra performance, can be done basically and quite simply using the steps Stuart gave then just repeating Read, Write, Read, Write etc.
|
|
|
|
|
Hi All
How can i get USB Drive Letter size?Plz help me
|
|
|
|
|
NewVC++ wrote: Drive Letter size?
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Drive letters are generally 1 big.
If you want to know the size of a drive (whether USB or not), the GetDiskFreeSpaceEx should help you.
And GetDriveType helps you a bit to find out the (shockingly) drive type.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
you mean the hight or width of USB drive letter.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
No dear _$h@nky_
His/her answer is GetDiskFreeSpaceEx .
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Hey,
I'm trying to make a server and a client application. I'm having a problem tho. I set up an async server and an async client, then have the client to connect to the server, this part works. Once I receive the FD_ACCEPT message I call accept(wParam, NULL, NULL) to accept the connection, but this is where the problem occurs. The client doesn't receive the FD_CONNECT message and I can't for the life of me figure out why.
INT_PTR CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case INCOMING_TRAFFIC:
{
switch (WSAGETSELECTEVENT(lParam))
{
case FD_CONNECT:
{
MessageBox(0, "Connected", "", 0);
const char * SendMsg = "Send message...";
send(wParam, SendMsg, strlen(SendMsg), 0);
} break;
case FD_READ:
{
char buffer[19671] = {0};
recv (wParam, buffer, sizeof(buffer)-1, 0);
MessageBox(hwnd, buffer, "Captured Text…", MB_OK);
}break;
case FD_CLOSE:
{
MessageBox(0, "Connection lost...", "", 0);
closesocket(wParam);
WSACleanup();
exit(1);
} break;
}
} break;
default:
return false;
}
return true;
}
That's the message thread for the client, it does receive messages (when I disconnect the server it receives the FD_CLOSE message), but it's not receiving FD_CONNECT. I'd appreciate some help, I can post more code if you need it.
|
|
|
|
|
I presume you correctly asked to receive connect messages in your WSAAsyncSelect call?
One tangential thing - I've seen sites suggest that this form of asynchronous socket isn't great, as it depends on the window's message queue, and high traffic rates can be problematic. Overlapped IO - initiated by setting the WSA_FLAG_OVERLAPPED flag in your WSASocket call - is suggested as a better alternative for asynchronous socket IO.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I'm new to sockets, I don't really get what you mean, sorry.
|
|
|
|
|
Which bit don't you understand?
If it's the bit about WSAAsyncSelect, then I'm saying that in your call to WSAAsyncSelect (which you must have, to make the socket non-blocking), the fourth parameter is a bitmask that specifies the socket events you want to receive.
If it's the second bit, about overlapped IO - never mind, forget I ever mention it
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I want to create a temp file do some process and delete it.
I've create a temp file like this.
szTempFile = new TCHAR[MAX_PATH];<br />
<br />
if(!::GetTempFileName(".","temp",0,szTempFile))<br />
{<br />
return -1;<br />
}
It's creating a temp file on the current working folder.
Then I try to delete the file as follows.
<br />
if(szTempFile != NULL)<br />
{<br />
HRESULT b = ::DeleteFile(szTempFile);<br />
}<br />
This not delete the file. When I check the path it's valid but the result of parameter b is 0.
Can someone help me to find the error.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
Call GetLastError after DeleteFile and check what it returns.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Yes, I got the error code as 32.
I'm mess with the finding what it means.
I appreciate your help all the time...
CodingLover
|
|
|
|