|
|
HI ,
I struck in below scenario. please put some light on it.
I have one combobox and edit control in win32 application.
1. i keep on updating my combobox with new data, but while doing that, previous data in combobox missing.
2. when i choose one data item in combobox corresponding value should be updated in edit box.
Thanks,
Goutham.
|
|
|
|
|
Gday.
1. How are you updating the combo box? Please show some code
2. You simply handle CBN_SELENDOK notification messages, when you get one - you ask for the currently selected string then send it to the edit-control.
Note: Selecting an existing item and typing an item into the edit box of the combo-box control send different messages. If you can't(shouldn't) type into the edit box, you should probably be using a list control instead.
CBN_SELENDOK[^]
|
|
|
|
|
|
Hi,
I am trying to Capture Keystrokes of a Richedit using the vitrual Cdialog::Pretranslate
When I override the virtual function I am getting a access violoation
would it be possible Pretranslate is capturing the debuggers keystrokes
Would I need some directive like if !DEBUG
any help appreciated
|
|
|
|
|
Try commenting out all of the code in your override function. Does the access violation still happen?
If it does not, then the problem is your code, which you can post here for some help.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hi,
it doesn't happen when I comment out the code
Here is the code to the override for PreTtanslateMessage
<pre lang='cpp'> BOOL CprogDebug::PreTranslateMessage(MSG* pMsg)
{
CHERC_CMDApp *main_app;
MyBaseEvent* myeventptr;
if(pMsg->message==WM_KEYDOWN)
{
if(pMsg->wParam==VK_RETURN) // enter key
{
main_app = (CHERC_CMDApp *)AfxGetApp(); // get main app
myeventptr = main_app->mybaseeventptr; // get event class
strcpy(myeventptr->buffer_ptr," "); // single step
myeventptr->send_window = this; // return to this window
myeventptr->SetEvent(); // signal event
}
}
return CDialog::PreTranslateMessage(pMsg);
} </pre>
|
|
|
|
|
My guess is that myeventptr->buffer_ptr might be null or it might point to unallocated memory.
Step through the code with the debugger and see on which line it crashes.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Countered the bloody univoter.
|
|
|
|
|
Hi,
I have a couple of standalone applications, all written using MFC, which I want to combine them as an application suite.
My company's strategy is writing new applications using Qt. So some day I may be forced to rewrite them using Qt.
In this situation, I have two questions:
1. Do you recommend me to develop new application suite using Qt or not?
2. Which is the best way to combine them? Make plug-in versions of my standalone apps? Make COM versions of my standalone apps? Make libraries of their core functionality and use them in a new UI? Or simply place their codes in a new solutions containing multiple projects, use their individual outputs as standalone projects and use their code in the integration project at the same time? Or what ever you say?!...
|
|
|
|
|
I think there's really no simple answer to this and will depend a lot on your application, the complexity of it and how it will be used.
1. It depends, in a complex application... this may take a long time. Do you have any time constraints? I've never really done a ton in Qt, but I've heard some of our employees who have used it complain about it. In case you've never used it, try with a small application to gauge how painful the move will be.
2. Again, this depends a lot on what your applications do. The plug-in idea is good for certain things, such as ease of expandability, but can cause short-term headaches and support issues (it's easier to break). I can probably go on and on with positives and negatives of each approach but really it just depends on what you need:
- Be able to communicate with apps built in different languages/frameworks (COM)?
- Easily expandable (plug-ins/libraries)?
- Save time in development (time is money after all, multiple exes option)?
- Expect core functions not to change much (library)?
- Expect core functions to be able to be used in multiple projects (library)?
- Do the applications need to do everything they do simultaneously? If not, does it make sense to keep different functionality in some logical grouping (like MS Office, does it make sense to have Excel and Outlook be one program? not likely)?
|
|
|
|
|
Those are good tips for me to consider, Thanks a lot!
Do you have any reference or clues for me to learn more about application suite development?
|
|
|
|
|
Not really... I'm a developer/engineer for a suite of tools, there's multiple exe's, shared libraries (dlls and libs), COM interfaces (for some tools), so there's really no magic method for building suites. It really is requirement driven, so approach it as such. What does your customer want/require?
|
|
|
|
|
hello guys... I am trying to change the text color of an item in a CListCtrl in which I am successful, thanx to some online tutorials. But now I am trying to change text color based on the value of a static boolean variable. Here is what I am trying
void CMainDlg::OnStatusList_CutomDraw(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMCUSTOMDRAW pNMCD = reinterpret_cast<LPNMCUSTOMDRAW>(pNMHDR);
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
*pResult = CDRF_DODEFAULT;
if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
*pResult = CDRF_NOTIFYITEMDRAW;
else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
{
COLORREF crText;
if(IsItemNumEven)
crText = RGB(255,0,0);
else
crText = RGB(0,255,0);
pLVCD->clrText = crText;
}
*pResult = CDRF_DODEFAULT;
}
This piece of code generates no error but it does not change the color either. If I remove the condition on IsItemNumEven , then it works fine. Just for general info, can I do something like this
AddToList("Item Index is Even");
MyListControl.SendMessage();
Thanks for any pointers.
This world is going to explode due to international politics, SOON.
|
|
|
|
|
Why don't you use the debugger to see the runtime value of IsItemNumEven ?
Veni, vidi, vici.
|
|
|
|
|
I would certainly do that if I am able to hit the break point in this function. It never goes there and I have no clue why.
This world is going to explode due to international politics, SOON.
|
|
|
|
|
It should reach that point, you stated it works if you remove the flag, right?
Veni, vidi, vici.
|
|
|
|
|
Overloaded_Name wrote: if(IsItemNumEven)
Why don't you look at pLVCD->nmcd.dwItemSpec instead?
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
i want the user give me number.and i will setup queue with this number of zero.(case e) i get error to copile and i dont know why.
#include <iostream>
#include <list>
#include <deque>
using namespace std;
char option()
{
char c;
cout<<"A push valu\n"; cout<<"B pop valu\n"; cout<<"C the first valu in list\n"; cout<<"D is empty\n"; cout<<"E build queue\n";
cout<<"F print list\n"; cout<<"G print queue\n";
cout<<"H exit\n";
cout<<"selecte:";
scanf("%c",&c);
return c;
}
void main()
{
typedef deque<int> j;
list<int> v;
list<int>::iterator i;
int x;
char c;
do
{
c=option();
switch(c)
{
case 'a':
cout <<"enter number:";
cin >> x ;
v.push_back(x);
cout << endl;
flushall();
break;
case 'b':
if(v.empty())
cout<<"the list empty\n"<<endl;
else
{
v.pop_back();
cout <<"pop form back done\n"<<endl;
}
flushall();
break;
case 'c':
if(v.empty())
cout<<"the list empty\n"<<endl;
else
{
i=v.begin();
cout<<*i<<endl;
}
printf("\n");
flushall();
break;
case 'd':
if(v.empty())
cout<<"the list empty\n"<<endl;
else cout <<"there is somting in the list\n"<<endl;
printf("\n");
flushall();
break;
case 'e':
int numbers;
cout<<"how many number you want in queue:";
cin >> numbers;
j a(numbers,0);
printf("\n");
flushall();
break;
case 'f':
for (i=v.begin(); i != v.end(); ++i)
cout << *i << " ";
cout <<"\n"<< endl;
flushall();
break;
case 'g':
printf("\n");
flushall();
break;
case 'h':
cout <<"bye\n"<< endl;
exit(1);
default :
cout <<"no such option\n"<< endl;
flushall();
break;
}
}while(c!='h');
}
|
|
|
|
|
You need to explicitly scope variables created inside a case statement.
So case 'e' must look like this (with braces) -
case 'e':
{
int numbers;
cout<<"how many number you want in queue:";
cin >> numbers;
j a(numbers,0);
printf("\n");
flushall();
}
break;
|
|
|
|
|
That would be correct, but probably useless.
Veni, vidi, vici.
|
|
|
|
|
thanks very helpful but now i have problem to print (case g)
#include <iostream>
#include <list>
#include <deque>
using namespace std;
char option()
{
char c;
cout<<"A push valu\n"; cout<<"B pop valu\n"; cout<<"C the first valu in list\n"; cout<<"D is empty\n"; cout<<"E build queue\n"; cout<<"F print list\n"; cout<<"G print queue\n";
cout<<"H exit\n";
cout<<"selecte:";
scanf("%c",&c);
return c;
}
void main()
{
typedef deque<int> j;
deque<int>::iterator p;
list<int> v;
list<int>::iterator i;
int x;
char c;
do
{
c=option();
switch(c)
{
case 'a':
cout <<"enter number:";
cin >> x ;
v.push_back(x);
cout << endl;
flushall();
break;
case 'b':
if(v.empty())
cout<<"the list empty\n"<<endl;
else
{
v.pop_back();
cout <<"pop form back done\n"<<endl;
}
flushall();
break;
case 'c':
if(v.empty())
cout<<"the list empty\n"<<endl;
else
{
i=v.begin();
cout<<*i<<endl;
}
printf("\n");
flushall();
break;
case 'd':
if(v.empty())
cout<<"the list empty\n"<<endl;
else cout <<"there is somting in the list\n"<<endl;
printf("\n");
flushall();
break;
case 'e':
{
int numbers;
cout<<"how many number you want in queue:";
cin >> numbers;
j a(numbers,0);
printf("\n");
flushall();
}
break;
case 'f':
for (i=v.begin(); i != v.end(); ++i)
cout << *i << " ";
cout <<"\n"<< endl;
flushall();
break;
case 'g':
for (p=a.begin(); p != a.end(); ++p)
cout << *p << " ";
cout <<"\n"<< endl;
flushall();
break;
case 'h':
cout <<"bye\n"<< endl;
exit(1);
default :
cout <<"no such option\n"<< endl;
flushall();
break;
}
}while(c!='h');
}
|
|
|
|
|
You should really give better descriptions of the errors.
However, in this case, the problem is that a variable has limited scope and case 'g' cannot see it (already destroyed).
You better declare a (using default constructor) before entering the switch block and then populate it in case 'e' .
Veni, vidi, vici.
|
|
|
|
|
You must include stdio (use #include <cstdio> ) in order to use scanf , printf , etc.
Veni, vidi, vici.
|
|
|
|
|
Woa there Tex! Three are the things that jump out at me reading your code:
- switch statement from hell. At least call a function per case statement rather than piling all your code in one place
- mixing cstdio with iostream . Don't do it unless you're an expert. If you are an expert think twice about why you need to mix them.
- don't bother using exit(n); in main . return n; has the same effect.
The error you're getting is going to be something like "initialization of variable is skipped by switch statment." What that means is if someone enters 'f', 'g', 'h' the constructor for a won't be called. The flow of control goes galloping past, jumping over the initialisation of a. In your case this isn't a problem as a isn't used elsewhere. To get around this either stick everything that's currently in a case statement in a function OR use an additional level of scope around your case statement. I'd go for functions personally as scoped cases can get a bit ugly:
case 'e':
{
int numbers;
cout<<"how many number you want in queue:";
cin >> numbers;
j a(numbers,0);
printf("\n"); flushall();
break;
}
break;
Anyway, hope that helps. If not shout and we'll see what we can do to improve our answers.
Edit: Realised that I'd said the wrong set of case statements avoided calling the constructor. Hopefully corrected that now!
modified 29-May-12 6:37am.
|
|
|
|