|
|
|
Thank you!
|
|
|
|
|
When trying to find out this kind of thing, go to the help index and look at the class members. This provides a list of functions available for the class, saves a lot of time and you learn quite a bit in the process.
Elaine
The tigress is here
|
|
|
|
|
Hi. Im trying to get more control over a scroll bar from a ClistCtrl. I tried to use the "Flat Scroll Bars" from win SDK but they behave weird when i drag them. All the rest works fine, except from that weird behavior.
My code:
m_list=new CListCtrl();
m_list->Create(WS_BORDER | WS_VISIBLE | WS_CHILD | LVS_REPORT | LVS_SINGLESEL | LVS_NOCOLUMNHEADER, CRect(0,0,0,0),this,NULL);
::InitializeFlatSB(m_list->m_hWnd);
::FlatSB_ShowScrollBar(m_list->m_hWnd,SB_VERT,true);
::FlatSB_EnableScrollBar(m_list->m_hWnd,SB_BOTH,ESB_ENABLE_BOTH);
::FlatSB_SetScrollProp(m_list->m_hWnd,WSB_PROP_VSTYLE,FSB_FLAT_MODE,false);
::FlatSB_SetScrollProp(m_list->m_hWnd,WSB_PROP_CXVSCROLL,25,false);
Thanks in advance
|
|
|
|
|
My program needs to query a number of servers for data. I can do this by repeating the following:
for (each server)
{
Create socket
Connect socket to server
Close socket
}
What I want to do is use the same socket to connect to each server in turn so that I only have to create the socket once:
Create socket
for (each server)
{
Connect socket to server
Disconnect socket
}
Close socket
Is this possible? My socket is a CSocket.
Thanks
|
|
|
|
|
No. It is possible, however, to recreate a new socket and assign it to the socket handle in the same object.
Kuphryn
|
|
|
|
|
Sometimes I need to compare two boolean values, for example:
BOOL b1 = condition1();
BOOL b2 = condition2();
if (b1 == b2) // both TRUE or both FALSE
{
// something
}
else
{
// something else
}
Above code makes sense but actually I guess they are wrong, since BOOL's are actually INT's, while "false" is guaranteed to be "0", "true" is only guaranteed to be "non-zero" ---- in theory, it may or may not be "1", so even if b1 and b2 are both true, they don't necessarily equal to each other.
Although I can do this instead:
if ((b1 && b2) || (!b1 && !b2))
{
// something
}
else
{
// something else
}
This sure will work but looks ugly, my question is, how to compare two BOOL values in a way that the code works AND looks not ugly?
|
|
|
|
|
=[ Abin ]= wrote:
if ((b1 && b2) || (!b1 && !b2))
I don't think it looks that ugly, but you could always write a function to handle the comparison for you.
-Nick Parker
|
|
|
|
|
Maybe you can write your BOOL class and overload the operator "==".
YES, I am here.
|
|
|
|
|
(!b1) != (!b2)
looks better?
t!
|
|
|
|
|
I agree with Nick. If you think it looks ugly, write a function (make it inline for speed...). I don't think it looks ugly and is exactly what I would do.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
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 the == operator disregards the "non zero" value, just assums it like "1". If that happnes, "if (b1 == b2)" is absolutly correct
|
|
|
|
|
I don't think what you wrote is ugly. I'd only add an explicit comment before the if .
if ((b1 && b2) || (!b1 && !b2)) {
something;
} else {
something else;
}
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
That's why I always use bool instead of BOOL
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
I would use bool, but I don't think the following code is all that bad:
if( !b1 == !b2 )
{
}
else
{
}
Chris Richardson Terrain Software
|
|
|
|
|
hello @all,
i want to fill a CString. i tried this:
hs1=0;<br />
CString m_strTest1;<br />
CString minus("-");<br />
m_strTest1.SetAt(hs1, 'minus');
but it does not work.
can anybody help me?
thanks,
sunny
|
|
|
|
|
hi...
you have made an error.
<br />
void SetAt(<br />
int iChar,<br />
XCHAR ch<br />
);
CString::SetAt can add only char.not word!!
what do you want to do?
|
|
|
|
|
What do you do?
Use this code for filling a CString variable:
CString var=_T("Hello World!");
Now, var filled with "Hello World!" string.
A. Riazi
|
|
|
|
|
Sunnygirl wrote:
m_strTest1.SetAt(hs1, 'minus');
SetAt() expects a character, not a string. You've given a string but encoded it as a character. This will spit out a compiler warning, and is not correct. Just do this;
CString m_strTest1;
m_strTest1 = "minus"; Hope this helps,
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
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"
|
|
|
|
|
if you need to insert a string into certain position there is CString::Insert()
CString str;
str.Insert(0, "TEST");
|
|
|
|
|
Hi,I have a question when I was writing the program about serial communication.
It seems that most articles about serial communication are wrote to the characters transmission.But now I want to transmit files by serial ports,how could I do that.I mean "transmit files" is that copy files on a PC to another.
Is there anyone could give me a method to do that? Thanks very much.
YES, I am here.
|
|
|
|
|
It's very simple. Read file character by character and send this character to another PC by your serial interface. Another PC read these character and save them on a new file!
This article[^] has a sample demo for transferring files by Serial Port!
A. Riazi
|
|
|
|
|
Just sending characters is Ok for a simple application. To do it "properly" you need to use some protocol to prevent the loss of data, such as XMODEM, YMODEM, KERMIT etc.
I am sure you can easily find a freeware library for XMODEM or YMODEM, with these protocols you can also send the name of the file you are transfering, I can't rember if that one is XMODEM or YMODEM.
Happy hunting
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
Hi,
how can i show a CFrameWnd derived class like a modal dialog box (launched from a dialog box)?
The CFrameWnd derived class has a view attached.
regards....
Hari Krishnan
|
|
|
|