|
|
Thanks very much for your reply.
Yes, it will be very kind if you send me your sample. I'm fooled by it.
Send the sample to this email: albertkong1984@gmail.com
Thx.
|
|
|
|
|
The sample is already there in that link. Here is direct link[^]
|
|
|
|
|
Take a quick look at this link[^]">.
Regards,
Rane
modified on Thursday, September 4, 2008 11:59 PM
|
|
|
|
|
And how about adding two CToolBarCtrl in a dialog?
|
|
|
|
|
how can i give or set color of tabcontrol buttons (background color ) in visual c++ code.
|
|
|
|
|
|
hello all:
when i use NetWkstaUserGetInfo function
typedef struct _WKSTA_USER_INFO_1 {
LPWSTR wkui1_username;
LPWSTR wkui1_logon_domain;
LPWSTR wkui1_oth_domains;
LPWSTR wkui1_logon_server;
}WKSTA_USER_INFO_1, *PWKSTA_USER_INFO_1, *LPWKSTA_USER_INFO_1;
_WKSTA_USER_INFO_1 t;
char tm[100]={0};
NetWkstaUserGetInfo(NULL,1,(LPBYTE*)(&t));
strcpy(tm,(char*)t.wkui1_username);
"65168" is the t.wkui1_username value
why is not the current user name?
a beginner
|
|
|
|
|
alphaxz wrote: char tm[100]={0};
NetWkstaUserGetInfo(NULL,1,(LPBYTE*)(&t));
strcpy(tm,(char*)t.wkui1_username);
Since Unicode is defined, why not use:
TCHAR tm[100] = {0};
NetWkstaUserGetInfo(NULL, 1, (LPBYTE *) (&t));
_tcscpy_s(tm, _countof(tm), t->wkui1_username); alphaxz wrote: why is not the current user name?
Because t should be a pointer instead:
LPWKSTA_USER_INFO_1 t;
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
I can't understand what do you mean?
a struct or a point to a struct ,any difference?
a beginner
|
|
|
|
|
Just take a look at the below piece of code and hope you will be clear..
DWORD dwLevel = 1; // Specifies the information level of the data
LPWKSTA_USER_INFO_1 pBuf = NULL;
NetWkstaUserGetInfo(NULL,
dwLevel,
(LPBYTE *)&pBuf);
The 3rd parameter is the pointer to the buffer that holds the data.
A point to note here is that this function will work only locally and will fail if you try to enumerate the list of remote users...
Regards,
Rane
|
|
|
|
|
thanks all
I've got the answer
the difference between ansi and unicode
a beginner
|
|
|
|
|
alphaxz wrote: I can't understand what do you mean?
I gave you the code. What's not to understand?
alphaxz wrote: a struct or a point to a struct ,any difference?
Yes, a big one. Notice the third argument to NetWkstaUserGetInfo() is supposed to be a BYTE** . The second pointer is there so that NetWkstaUserGetInfo() can allocate memory for the structure.
Don't forget to call NetApiBufferFree() .
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
thank u very much
i've got the answer under your instruction
a beginner
|
|
|
|
|
In the parent window, I use a child window to group controls, and want the parent window to handle their messages. In other words, let the child window only deal with position problems. Does Windows have any mechanism that supports this?
system
|
|
|
|
|
I am not sure, but in MFC there is a mechanisam for changing the owner using thr SetOwner() function. That is, the controls send the message to the owner windows. So try specifying the parent window as the owner of the controls.
Optionally you can trap all the messages of the child controls using the PreTranslateMessage() function.
|
|
|
|
|
Hi All,
I am working on Serial port function using NonOverlapped I/O(using VC6.0).
My Application to be communicated with a hardware device with 115200 baud rate.
Im able to receive the data correctly if I place a Sleep(1), in between two characters.
If I remove the Sleep, the data im received is correct for a single write and
Read. If it is continuous the data is corrupted.But If Sleep is there the response time of my application is very slow.
My Code is:
<pre>BOOL PortReadThread (COMMN_CTRL_CLASS *pCCommnCtrl)
{
while (TRUE)
{
// Wait for a character in input buffer
WaitCommEvent(pCCommnCtrl->hCommn, &wEvent, NULL); //from NULL
do
{
// Sleep(1);
wToRead = pCCommnCtrl->ReadPort(&cRcvdByte,1);
if(wToRead>0)
{
Count++;
pCCommnCtrl->CopyRx(cRcvdByte);//process rxbyte
}
}while(Count<1);
}
CloseHandle(pCCommnCtrl->hReadThread);
return TRUE;
}
}
DWORD CCommnCtrl::ReadPort(BYTE *pBuff, DWORD nToRead)
{
if(!(ReadFile(hCommn, pBuff, nToRead, &wsidytesRead, NULL)))
{
if(GetLastError() == ERROR_IO_PENDING)
{
AfxMessageBox("PENDING");
}
else
{
wsidytesRead = 0;
ClearCommError(hCommn, &wErrorFlags, &comstat);
}
}
return wsidytesRead;
}
Communication time outs:
timeout.ReadIntervalTimeout = 0xFFFFFFFF;
timeout.ReadTotalTimeoutMultiplier =0;
timeout.ReadTotalTimeoutConstant = 0;
timeout.WriteTotalTimeoutMultiplier = 0;
timeout.WriteTotalTimeoutConstant = 0;
</pre>
If I place a Sleep(1), in ReadThread then even for continuous read and write the data is correct.But If I remove sleep, the data I receive is very fast but corrupted.
Please clarify If I need to chnage my code.
Regards,
Sunil Kumar
|
|
|
|
|
1/ Something went wrong with your pre tags.
2/ Read Flounder's essay on serial programming - it will hopefully help you avoid a few pitfalls...
http://www.flounder.com/serial.htm[^]
Iain.
|
|
|
|
|
I found this code:
cin.ignore(numeric_limits<streamsize>::max(), '\n');</streamsize>
to clear the input buffer but sometimes when I use it there's nothing in the buffer which results in the program stops and does not continue until I press Enter.
How can I check if there's anything in the buffer before I try to clear to prevent the program from stopping?
|
|
|
|
|
Because cin.ignore(std::numeric_limits::max(),'\n'); means ignore input upto the next newline. If there is no newline pending then you are going to have to input another.
Vikas Amin
My First Article on CP" Virtual Serial Port "[^]
modified on Thursday, July 24, 2008 5:33 PM
|
|
|
|
|
Sunday8PM wrote: How can I check if there's anything in the buffer before I try to clear to prevent the program from stopping?
What about cin.clear() or cin.flush() ?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Those do not clear the input buffer. Maybe clear it is not the word, I want to use cin.ignore but inside an if case telling me if there's anything in the stream.
I just looked at cin.peek() but I'm not sure how to use it, if I understand correcty it shows the next character in the stream but what should I campare the character to?
|
|
|
|
|
This is re-post, as I really could do with some help..
Hi.
I have a simple console app which I use to CreateProcess() other console apps with re-directed output streams so that I can get hold of their output with PeekNamedPipe(). I have just noticed, by accident (which does not say much for my intensive testing) that in the output from the DOS tree command, the nice ASCII angle and bar characters are encoded incorrectly (I think with the default windows encoding). My App is built using MBCS which I understand is OK for ASCII, what do I need to do to get an output identical to the command-line invocation of TREE.
Any thoughts are much appreciated.
James.
|
|
|
|
|
Hi, Mark directed me to the MSDN section about scrollbars this morning which helped a lot, but I still have one problem that I can't seem to solve:
Once again I'm using VC++ with MFC, and I have a CScrollBar that I want to use to scroll some custom controls.
I don't want to use the dialog's "built-in" scrollbar because it isn't in the right place and I have lots of other bits of data there, so I have a stand-alone CScrollBar control that I have mapped through DDX_Control to my dialog.
Since my scrollbar is stand-alone I had to subclass it in order to catch the WM_VSCROLL messages sent to its window when the bar is moved. This all works fine BUT ONLY when I have the scroll bar's style set as WM_VSCROLL. The style SHOULD be SBS_VERT, but when I make the style SBS_VERT instead of WM_VSCROLL, I no longer get any WM_VSCROLL messages in my subclassed process. What could I be doing wrong???
Also on a side note, it seems pretty ridiculous that I have to either subclass the control or overload it and handle OnVScroll explicitly to get the scroll bar to function. Is there a better way?
Thanks!
KR
|
|
|
|
|
You can catch the WM_VSCROLL message in the parent of
the scrollbar control. There's no reason to subclass the
control.
KellyR wrote: ONLY when I have the scroll bar's style set as WM_VSCROLL
WM_VSCROLL is a message, not a style, so it shouldn't be used as a style
If you don't specify SBS_VERT as a style, then the default is SBS_HORZ.
I tested this real quick - Here's all I did:
1) Added a scrollbar control (vertical) to a dialog
2) Right clicked the control and added a control variable (to the dialog's class)
3) Added a WM_VSCROLL handler to the dialog class.
Clicking on the scrollbar control sends a WM_VSCROLL to the parent
as expected.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|