|
if you run this code what happens?
<br />
#define IDC_TEST 1000<br />
<br />
BEGIN_MESSAGE_MAP(CAnswerDlg, CDialog)<br />
ON_BN_CLICKED(IDC_TEST, OnBnClickedTest)<br />
END_MESSAGE_MAP()<br />
<br />
void CAnswerDlg::DoDataExchange(CDataExchange* pDX)<br />
{<br />
DDX_Control(pDX, IDC_TEST, m_Test);<br />
}<br />
<br />
BOOL CAnswerDlg::OnInitDialog()<br />
{<br />
m_Test.Create("AS",WS_TABSTOP|WS_CHILD|WS_VISIBLE|BS_NOTIFY,CRect(0,0,100,23),this,IDC_TEST);<br />
}<br />
<br />
void CAnswerDlg::OnBnClickedTest()<br />
{<br />
MessageBox("A");<br />
}<br />
<br />
afx_msg void OnBnClickedTest();<br />
CButton m_Test;<br />
I run this code and it works for me does this code solve your problem?
|
|
|
|
|
Hi,
Regret for late reply...
I am using Win32 SDk application,no MFC is there.
I have implemented subclaasing of child controls(buttons in this case) to adrees this issue.Now I am able to handle enter key events as well.
Manish
|
|
|
|
|
I glad you find it
|
|
|
|
|
Hi all,
I'm trying to get the data from a file and assigning each of the lines to a variable (array or something)
I have tried the following:
<br />
HANDLE hFile;<br />
DWORD dwNumRead;<br />
BOOL bTest;<br />
char dwBuffer[256];<br />
<br />
hFile = CreateFile("client.cnf", GENERIC_READ, FILE_SHARE_READ,NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);<br />
bTest= ReadFile(hFile, dwBuffer, sizeof(char)*256, &dwNumRead,NULL);<br />
printf("%s",dwBuffer);<br />
I receive data from the file (dwBuffer), but how can I assign each line to an variable (array element or something)
Lets say the file has the following data:
[SEND]
file1.txt
file2.txt
[RECEIVE]
file3.txt
file4.txt
Thanx in advance
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
Why don't you use the MFC class CStdioFile it can read a file line by line.
Help your local Search & Rescue. Get lost!
|
|
|
|
|
Thanx for the reply Monty, but I'm not using MFC...
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
Then you can parse the string and break at every '\r\n' , alternatively you can use strtok
You can't see me
|
|
|
|
|
Thank you Monty, I'll check out MSDN...
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
« Programm3r » wrote: The only programmers that are better than C programmers are those who code in 1's and 0's.....
You forgot the assembly guys
OK, so what's the speed of dark?
|
|
|
|
|
LOL ... My bad....
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
Monty2 wrote: You forgot the assembly guys
...and the C# and HTML guys, from what they tell me.
|
|
|
|
|
|
|
Hi, I want to add ItemData as a string in my list box using win32 APIs. But when I try to get it back from list box I am getting blank string. Can I know what is wrong with my code?
Thanks in advance.
char setStr[20] = "test";<br />
char* getStr;<br />
<br />
::SendMessage(hLbox,LB_SETITEMDATA,listIndex,(LPARAM)setStr);<br />
testStr = (char*):: SendMessage (hLbox, LB_GETITEMDATA, listIndex, NULL);
|
|
|
|
|
priyank_ldce wrote: char setStr[20] = "test";
You are passing address of a local variable.
Create it on heap instead.
|
|
|
|
|
If you always pass constant strings like in your example, then try a different definition of setStr :
const char * setStr = "test";
::SendMessage(hLbox, LB_SETITEMDATA, listIndex, (LPARAM)setStr);
I hope this helps.
|
|
|
|
|
Hi, Thanks for the help. Actually I get that string in the form of char[]. Can I know how can I cast it to const char*. I tried strcpy() but it is not working.
|
|
|
|
|
In case of variable string values, I think you can try the following (old-fashioned) solution:
char setStr[20] = ...;
::SendMessage( hLbox, LB_SETITEMDATA, listIndex, (LPARAM)_strdup(setStr));
const char * str = (const char*)::SendMessage( hLbox, LB_GETITEMDATA, listIndex, NULL);
Note that these strings are allocated on the "heap" and therefore must be freed when the list control is destroyed, or new data are set. This can be done in OnDestroy handler of your dialog. You have to loop through list-box’s items and execute:
free((const char*)::SendMessage( hLbox, LB_GETITEMDATA, listIndex, NULL));
Modern solutions use functions other than strdup and free . I am not sure which is simpler.
I hope this helps.
|
|
|
|
|
from process code below
int i;
m_progress.SetRange(0,999);
m_progress.SetStep(1);
m_progress.SetPos(0);
for (i=0;i<1000;i++)
{
m_progress.StepIt();
}
During I process in "for loop".
I also want the dialog response my action such as minimize,move dialog etc.
How I write the code if I don't use thread function.
|
|
|
|
|
you MUST move this code into a worker thread if you want the GUI to respond...
|
|
|
|
|
Max++ wrote: During I process in "for loop".
I also want the dialog response my action such as minimize,move dialog etc.
How I write the code if I don't use thread function.
Hope this[^] article helps.
|
|
|
|
|
where you use this code ?
|
|
|
|
|
I would like to know how to detect the socket was blocked?
Also how to detect the network is disabled?
Please help!
|
|
|
|
|
LaHaHa wrote: I would like to know how to detect the socket was blocked?
When a socket is created it is in blocking mode until you change it. WSAAsyncSelct() and
WSAEventSelect() are two APIs that will change the socket to non-blocking mode. You can also
set the blocking mode with something like
// Set socket to non-blocking mode
DWORD dwNonBlockingMode = 1;
::ioctlsocket(hSocket, FIONBIO, &dwNonBlockingMode);
|
|
|
|
|
Thank you for your answering!
The blocking may be caused by the firewall, network cable disconnected or etc... So how to detect it? Please help!
|
|
|
|