|
A problem became apparent when I tried to run an app I have that utilizing the Dropdown arrows for toolbar buttons in Windows Vista. I haven't had much luck in the Vista forum, so I thought I'd approach my issue from a different angle and entertain the idea that it might not be related to Vista and maybe just something I'm doing wrong. Maybe it's been working on previous systems out of pure luck.
(I don't want it to be a crosspost, but in case somebody asks, the problem on Vista was the buttons end up too big vertically to fit in the toolbar)
Anyway, here's what I am adding to my CMainFrame::OnCreate to get dropdown arrows. I am also adding text to the right of the buttons. I'll assume I'm just using the "new" button for demonstration.
Am I doing this part correctly in general (2000, XP, etc...)?
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
//...
if (!m_wndToolBar.CreateEx(this,TBSTYLE_FLAT|TBSTYLE_LIST,
WS_CHILD|WS_VISIBLE|CBRS_TOP|CBRS_TOOLTIPS|
CBRS_FLYBY|CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
//...
m_wndToolBar.GetToolBarCtrl().SetExtendedStyle(TBSTYLE_EX_DRAWDDARROWS);
//...
m_wndToolBar.SetButtonStyle(m_wndToolBar.CommandToIndex(ID_FILE_NEW),
TBSTYLE_AUTOSIZE|TBSTYLE_DROPDOWN);
//...
m_wndToolBar.SetButtonText(m_wndToolBar.CommandToIndex(ID_FILE_NEW),"New");
//...
return 0;
}
|
|
|
|
|
Note: If you are not an expert on standard C++ or the STL, you may want to skip this one.
Restrictions:
1) Only standard C++ may be used.
2) Can not use ‘use_facet’ template, because that is not correctly defined by all suppliers (namely VC6.0).
3) Can not use any vendor specific extensions; like ‘_ismbtrail(…)’.
4) No knowledge of the code-page may be used.
I need to generate the missing characters in a range of multi-byte characters. My current implementation restricts sequences of characters to those with the same lead-byte, but I wish to eliminate that and ensure that no generated characters are invalid.
1) Example (Japanese: shiftjis):
Input range: Fullwidth digits “[0-9]” -> “[\x82\x4F-\x82\x58]”
Output sequence: “\x82\x4F\x82\x50\x82\x51\x82\x52\x82\x53\x82\x54\x82\x55\x82\x56\x82\x57\x82\x58”
That sequence is easy to generate because the lead bye is the same for all those characters and there are no gaps (invalid characters) in the sequence. The problem is that this places restrictions on the user – requiring them to know that all characters in range have the same lead-byte and that there are no gaps.
2) Example of lead-byte problem (Japanese: shiftjis):
Input range: “[\x82\xF1-\x83\x40]” -> [“Hiragana Letter N” – “Katakana Letter Small A”]
Output sequence: “\x82\xF1\x83\x40”
Unicode equivalent: “\x3093\x30A1”
In the above example it does not matter if a user is likely to enter that range, the code must be able to create the valid output sequence. As you can see the gap exists in both ShiftJis (MBCS) and Unicode.
3) Example (Japanese: shiftjis):
Input range: “[\x81\xE0-\x81\xDF]” -> [“Approximately Equal To Or The Image Of” – “Identical To”]
Output sequence: “\x81\xE0\x81\xDF”
Unicode equivalent: “\x2252\x2261”
In the above example both lead-bytes are the same, but there exist a gap of 16 invalid characters. This situation is easier to handle because I can actually use ‘mblen’ to check for valid 2-byte sequences, although I do not like this method.
4) Example (Japanese: shiftjis):
Input range: “[\xDF-\x81\x40]” -> [“Halfwidth Katakana Semi-voiced Sound Mark” – “Ideographic Space”]
Output sequence: “\xDF\x81\x40”
Unicode equivalent: “\xFF9F\x3000”
In this case the first character in the range is a single-byte (SB) character and the second is a double-byte character. Again it does not matter if a user is likely to enter that range; the code must be able to create the valid output sequence. Also note that the Unicode sequence is even worst than the ShiftJis sequence.
Note: All character sequences where retrieved from the ‘Character Map’ program and may not reflect the ‘locale’ sequence, which is part of the problem.
As you can see it is not a simple matter of incrementing the character as we would do in ASCII. There is no ‘istrail’ method in the standard and even if there was it may not be enough to solve the problem.
The following is the current implementation, which will only work for examples 1 and 3:
template<class StringType_>
void basic_regexp<StringType_>::insert_range(
string_set_type& c_set,
const string_type& s1,
const string_type& s2) const
{
if( s1.size() != s2.size() )
throw_char_range_error();
char_type lower = s1[0];
char_type upper = s2[0];
char_type leadbyte = 0;
if( s1.size() > 1 )
leadbyte = lower;
if( leadbyte )
{
if( lower != upper )
throw_char_range_error();
lower = s1[1];
upper = s2[1];
}
if( lower > upper )
throw_char_range_error();
string_type s;
for( ; lower <= upper; ++lower )
{
s.clear();
if( leadbyte )
{
s += leadbyte;
s += lower;
if( mb_len(s,2) != 2 )
continue;
}
else
{
s += lower;
}
c_set.insert(s);
}
}
I know of no algorithm that can solve the problems presented here. The solution must be similar in simplicity as the above implementation. I can envision a method to solve some of these problems, but it would be grossly inefficient.
If there is an example of a possible solution anywhere I would be interested.
Throw any ideas you may have at the problem, but please note that the restrictions are there to ensure portability. In other words it must be as usable as any STL implementation would be.
Thanks to any and all of those who may examine this problem, even if you can think of a solution worth posting.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
I don't understand the "No knowledge of the code-page may be used" part. The encoding (Shift-JIS, Big-5, etc.) defines which byte sequences are legal and illegal. If you can't use knowledge of the encoding, how can you tell which sequences are legal?
|
|
|
|
|
Michael Dunn wrote: how can you tell which sequences are legal?
There are two functions that can be used to determine that: isleadbyte and mblen .
Michael Dunn wrote: I don't understand the "No knowledge of the code-page may be used" part.
I added that restriction because I feel that it should be doable without that knowledge. For instance, I do not need that knowledge in order to determine if the bye is a lead byte or to determine if 2 bytes represent a single multi-byte character. There should be enough information buried in the STL some where to allow me to ignore the current code page.
That being said, I do have some C code (written for Win 3.1) designed to handle some MBCS code pages given the code page number. The code pages covered are Shift-JIS, Big-5, Korean, and etc…, which would be easy to convert to my current requirements.
The given code is the only place in the entire project where the knowledge is required and I did not want to have to provide code page specific code. I wish there was more support built into the standard for handling multi-byte, because I do not like having to fall back to functions defined in the C standard.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
hey I'm programming a moving model and wow it worked up to some degree.
Now I'm facing a problem that drives me MAD!
I split the model into nodes to traverse them. each node has different attributes:
<br />
class node<br />
{<br />
public:<br />
Vector pos;<br />
Vector rot;<br />
Vector orot;<br />
node *child;<br />
node *sibling;<br />
<br />
float animationStartTime;<br />
...<br />
};<br />
well actually thats not too important.
I'm traversing each node with a special function TraverseNodes:
<br />
void Model::TraverseNodes(node _node)<br />
{<br />
glPushMatrix();<br />
if (_node.animated)<br />
_node.animate(gettime);
<br />
TransformNode(_node);<br />
DrawNode(_node);<br />
<br />
if (_node.child != 0) TraverseNodes(*_node.child);<br />
glPopMatrix();<br />
}<br />
the marked line makes trouble! in this function I change the value of "float animationStartTime". It works the node's attribute is set correctly but when I leave the TraverseNodes-function the attribute of the node is reset (I can see it during debugging).
Why is the local variable changed (temporarily) but not overwritten?
thx in advance
|
|
|
|
|
should that member be static (common to all instances) ?
|
|
|
|
|
it should not be static and it works as long the function is not quit.
when the function is called again the node's attributes (namely animationStartTime) is the one from initialisation.
Something strange happens here and I donnu what
|
|
|
|
|
Here is a question for me why some your answers (not all) are getting 1 vote,today.I think if we could see name of voters then we can ask of them why you give low vote to a question.
|
|
|
|
|
I don't know... idiots are everywhere
|
|
|
|
|
zqueezy wrote: Why is the local variable changed (temporarily) but not overwritten?
Don't you need to pass a reference (or a pointer) to a "node" to the Model::TraverseNodes
method if you want the changes to stick?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Well you're damn right!
thanks Man
I didn't think of that!!!!
|
|
|
|
|
Hi thre,
Could anybody tell me what/how is the best way to generate a HeartBeat for a C++ application to check the integrity of the socket connection to another server/client machine?
Thanks for the help
|
|
|
|
|
Check out the socket option "SO_KEEPALIVE" in your help.
Phil
|
|
|
|
|
Unfortunately there is none built-in (at least SO_KEEPALIVE won't give you a very useable solution), you probably want to implement an application specific keep-alive mechanism (e.g. for a faster detection time of dead connections). I can recommend reading the book "Effective TCP/IP Programming" from Jon Snader which discusses this topic among others. A book worth to have on a desk or book shelf not far away from you.
Anyway, I did't want to end the discussion here. One solution that I use in my own software: a timer that triggers sending short amount of data to the clients, in case the connection is down I will receive an error in my OnClose() handler. The timer intervall depends on your requirements, currently I use 120 seconds which gives my application reasonably quick notification.
[answered twice]
|
|
|
|
|
|
Hi thre,
Could anybody tell me what/how is the best way to generate a heartBeat for a C++ application to check the integrity of the socket connection to another server/client machine?
Thanks for the help
|
|
|
|
|
Send data in regular intervals, if the connection is down you will be notified (TCP write operation returns error).
|
|
|
|
|
I've been thinking about selecting a compiler out of many of those out there but cant decide upon. Suggestions?
|
|
|
|
|
<quote>The Codeproject, Your Visual Studio and .NET Resource</quote>
Visual C++ 7.1 mostly, but VC6 some times. i installed VS2005, but can't migrate to it for now
|
|
|
|
|
But what is the difference between VC6, VC7.1 or VS2005 or even .NET for that matter?
|
|
|
|
|
Code2326 wrote: VC6, VC7.1 or VS2005
Kind of obvious; they are different versions.
|
|
|
|
|
You're being a bit terse here aren't you? In response to your comment the question becomes, "what is the difference between the versions?"
Steve
|
|
|
|
|
I did but the second question was a side question. I was asking why use an older version when you can use a newer one with more features etc., thats why i asked why it was different.
|
|
|
|
|
I want to start an independent application with parameters
from my current application.
requirements:
1) Independent appllication should not have relationship with the current application
in the form of starting of application.
2) Application shuold function as it is started by the local user.
3) Many applications requires parameters to run i should able to set that parameters.
4) My application is the table of other applications from where at given time current
application will automatically starts independently with set parameters.
Viral Joshi
|
|
|
|
|