|
In my CSocket client program, when I repeatedly relogon from one client, I see "Socket Notification Sink" exception.
I read some posts on the forum about this error, which said: dummy window and something else - anyway, it is bad design of CSocket.
In my case, I guess the exception is around function CSocket::Close(), CSockt::Connect() and CSocket::Send() for sending first message. I also guess the exception is caused by if CSocket is not ready for use.
I used try-catch, but the exception can not be catched.
Do you have any comments to avoid the exception?
BTW: do raw socekt functions have the problem?
|
|
|
|
|
You could always use Winsock functions directly, and avoid CSocket altogether.
|
|
|
|
|
Have you noticed that he's just posted the same thing below? He's given it one hours time, and after not responding to any queries that David asked, he deleted his previous query and started a new thread (same title, same contents, no more information).
Ignore that idiot.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
|
includeh10 wrote: ...anyway, it is bad design of CSocket.
Are you implying that the problem could not be in your code?
includeh10 wrote: Do you have any comments to avoid the exception?
Yes. Fix the code that is causing the exception. Now before you get your undies all in a bunch and whine that my suggestion is not helpful and ban me from commenting further, think about the question you've asked and if you really think you've provided enough information for us to be helpful.
includeh10 wrote: BTW: do raw socekt functions have the problem?
Have you tried using them to narrow the problem down?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hey guys,
So I have a directive like this:
#define NOOB_ME 1
Now let's say I have the following char array:
char buf[] = "NOOB_ME"
I want to store the char array in an int variable so that when I do a printf I should get a 1 (as per the value of the directive). Example:
int num = buf(I know this assignment is incorrect, but I want it to be the same as int num = NOOB_ME which is valid and produces an output 1)
Is there any way to get this done?
modified on Wednesday, November 4, 2009 3:32 PM
|
|
|
|
|
nikhil_86 wrote: char buf[] = "NOOB_ME"
The preprocessor is not going to mess with string literals. In other words, buf is going to contain "NOOB_ME" not "1" .
The rest of your post is nonsensical. What exactly are you trying to do?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I am aware of that, my question wasn't that. Let me elaborate. To let you know what I'm really doing, I am reading keys from the keyboard and the keyboard definitions are in a input.h file in linux.
So for example KEY_A has a value of 30. So when the user types the letter A, I store A in a char array which is concatenated with "KEY_". So basically I have a char array which stores KEY_A. Now I want to set a field called event.code = KEY_A, so I do not know how to do this. Does this make any sense?
|
|
|
|
|
nikhil_86 wrote: Now I want to set a field called event.code = KEY_A, so I do not know how to do this.
What type is event.code ?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
its of type int
so #define KEY_A 30
the thing is I want event.code to be whatever the user types. so I want it to be different everytime.
|
|
|
|
|
What are you using to "intercept" keystrokes (e.g., getch() , WM_CHAR )?
'a' has a value of 97; 'A' has a value of 65. To base those from 30, subtract 67 and 35 respectively. In other words:
event.code = key_pressed - 67;
event.code = key_pressed - 35; If that works, it might be a tad more intuitive to do:
event.code = (key_pressed - 'a') + KEY_A;
event.code = (key_pressed - 'A') + KEY_A;
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
A was just an example. I need it to be dynamic, so I should be able to use KEY_B KEY_C etc. Basically whatever the user types
|
|
|
|
|
And my example would do just that.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I suppose his dynamic prescinds even from alphabetic order...
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]
|
|
|
|
|
At runtime KEY_A simply doesn't exist, so why bother? Store directly user input.
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]
|
|
|
|
|
Uhm... Could you please elaborate a bit?
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]
|
|
|
|
|
You can not really store a string as an int - no one can do it in the world.
May you want to match an index as a string? if so, use a index-string map.
|
|
|
|
|
includeh10 wrote: You can not really store a string as an int - no one can do it in the world.
I can:
#include <stdio.h>
void main()
{
int i=0x006F6F66;
printf("%s\n",(char*)&i);
}
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]
|
|
|
|
|
I have a 3 pane StatusBar created in class CJBK_III_SBarCls as defined in the header file as:
CJBK_III_SBarCls : public CWnd
{
CStatusBar m_CJBK_III_SBar;
............... Stuff ..............
In CJBK_III_SBarCls.cpp:
}
int CJBK_III_SBarCls::OnCreate(LPCREATESTRUCT lp_CS)
{
#define SB_STYLE_EX = WS_EX_STATICEDGE | SBARS_SIZEGRIP | SBT_TOOLTIPS | SBT_OWNERDRAW
#define SB_STYLE WS_CHILD | WS_VISIBLE | CBRS_BOTTOM
m_CJBK_III_SBar.CreateEx(m_pCJBK_III_MF, SB_STYLE_EX, SB_STYLE, ID_OBJ_SB_CLS);
............... Stuff ..............
}
This seems to work fine, including putting text and bitmaps on or into the panes. I further wish to be able to have tool tips for each pane.
If I do this in CJBK_III_SBarCls.cpp:
m_CJBK_III_SBar.GetStatusBarCtrl().SetTipText(0, _T("This is Pane 0"));
m_CJBK_III_SBar.GetStatusBarCtrl().SetTipText(1, _T("This is Pane 1"));
m_CJBK_III_SBar.GetStatusBarCtrl().SetTipText(2, _T("This is Pane 2"));
Everything compiles, links and visually displays OK. Putting the mouse over any of the panes however, does nothing.
1. What am I missing?
2. Do I hve to create a CToolTipCtrl within the class?
3. If I don't have to create a CToolTipCtrl, how does one set things like text colors, delay times, .Activate etc.?
I am trying to follow "ms-help://MS.VSCC.v90/MS.MSDNQTR.v90.en/dv_vclib/html/7505a1f3-0c37-4cb1-b30b-af83f75bdf91.htm" in the help files.
A link to an example or simple example would be quite helpful.
Thanks,
Barry
|
|
|
|
|
This post can get deleted - I hoped to take the replies with it.
modified on Wednesday, November 4, 2009 2:50 PM
|
|
|
|
|
nope...
(I'm not familiar with PHP, but it is probably creating "dummy" associative arrays for each new variables)
This signature was proudly tested on animals.
|
|
|
|
|
Why do you need to do such a thing in C++.
You could always create dynamic arrays using a vector .
std::vector<std::string> name;
for (unsigned i = 0; i < 10; ++i)
name.push_back("some value");
You can access the vector elements like -
for (unsigned i = 0; i < 10; ++i)
cout << name[i].c_str();
|
|
|
|
|
Im not really looking to using vectors.
Ah well I think I'll do it otherwise then :p
Thanks anyhows!
|
|
|
|
|
a map would be much better for this, IMO.
|
|
|
|
|
In the Solitaire game, when you are moving the card around, it moves "over"' the other cards. I'm trying to figure out how this is done using either of the draw-related functions within cards.dll. I can move a card around on the playing area just fine. If that card moves over any of the other cards, it will erase them. If I add invalidating code to the end of the OnMouseMove() function, the card I am moving becomes obscurred by the other cards constantly being redrawn. What can I do to ensure that the card I am moving stays atop the other cards and at the same keep those other cards updated?
Unless there's no other way, I'd like to use the functions provided in cards.dll if I can. I've done very little in regards to GDI so my problem(s) here may be elementary.
Thanks.
- DC
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|