|
I've got an MFC dialog box with a combo box and several text boxes. I have to know what item in the combo box is selected in order to display the right content in the text boxes. Right now I have it set up so that when the user clicks a button it executes this segment:
CurrentSelection = ComboBoxPtr->GetCurSel();
CurrentContact = m_pMainWnd->OperationsClass.PhoneBookClass.ReturnContact(CurrentSelection);
//update text boxes based on name combo box selection
UpdateContactTextBoxes(CurrentSelection);
How can is I set it up so that it will detect when the user makes a change in the combo box, gets the current selection, and automatically executes UpdateContactTextBoxes(CurrentSelection), all without using a button? I saw a tutorial on how to do it with a wizard, but can anyone tell me how to do it with straight MFC code? I hate wizards.
|
|
|
|
|
Use events associated with the combo box.
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
Just add a handler to CBN_SELCHANGE message and put your code there..
|
|
|
|
|
CoffeeAddict19 wrote: How can is I set it up so that it will detect when the user makes a change in the combo box,
Use CBN_SELENDOK .
|
|
|
|
|
Thanks for your help. I got it working now.
|
|
|
|
|
How do I create NCB file with Visual Studio 6 so I can have intellisense enabled? Thanks
Norman Fung
|
|
|
|
|
It will be created automatically when opening project
|
|
|
|
|
What if it isn't? I rebuild the project many times and it is not there. NCB files must be a compiler option somewhere...
Norman Fung
|
|
|
|
|
The intellisense database is rebuilt when you open the solution/project, not when you rebuild it.
I'm not sure where the options are in VC6 but look in help for Intellisense. In VS2003 the settings are in the Tools|Options dialog in the Text Editor section.
Mark
|
|
|
|
|
Hi,
I have two list boxes ( ListBox1 and ListBox2 ) and an EditBox ( Edit1 ) box.
1. Select an item in ListBox1.
2. Enter a string in EditBox and Press Enter Key.
3. The String will go to ListBox2.
4. Like that add any number of items by selecting an item in ListBox1.
Problem : When we select an item in ListBox1, ListBox2 should display all the items we entered under ListBox1 dynamically. How I can achieve this ?
It's kind of fun to do the impossible.
|
|
|
|
|
Create in memory a data structure to store all items in Listbox2 associated with each item in Listbox1. A dictionary or hashing table will be appropriate. When adding an item to listbox2, again adding it to that data structure. When selected item in listbox1 changed, reload all items associated with listbox1 selected item to listbox2.
Hope that helps
|
|
|
|
|
Think about using a collection class for storing the data(CMap will be better choice)..
Put the item in list1 as "Key" and the items corresponding to it in List2 as "value"(use CStringArray here).
|
|
|
|
|
I would like to know how to disable the joystick by programming?
Please help!
|
|
|
|
|
I have a appication to load menu from resource, and want to change the menu style dynamically from "POPUP" to "STRING".
I wrote the following code:
pSubMenu->ModifyMenu(6,MF_BYPOSITION|MF_POPUP,(UINT)m_Menu.m_hMenu,"xxxM(&I)\tI");
m_Menu is a pop menu.
And now i want to change the menu style to "STRING":
pSubMenu->ModifyMenu(6,MF_BYPOSITION|MF_STRING,(UINT)IDM_RECV,"xxxM(&I)\tI");
The menu caption and icon was changed, but the menu was still "POPUP" style.
Who can tell me how to solve this problem?
Help!!!
-- modified at 22:52 Thursday 23rd November, 2006
hi
|
|
|
|
|
Hello, where can I found an example to communicate with a database in windows mobile (in native c++ and simple sql strings)
I found on the net that I must use OLEDB with SQL Server Mobile
In java it's very simple to do that
thx
|
|
|
|
|
What kind of database do you have or need?
Do you plan to have the data locally? I have worked on a mobile application where we just took a snapshot of data as XML locally. We could then just use some standard XML access code for navigating the data.
|
|
|
|
|
hi, I need a real database with sql support for insert records and also query the database
|
|
|
|
|
I assume Java worked because you had a library you could use. So maybe you could take the same approach with implementing this in C++, look for a library.
Gooling I found: http://www.sqlapi.com/[^]
If your mobile database does not need to connect to another database then you could choose any database supported by the library you choose to use. You might want to look around more to find one with a small foot print.
|
|
|
|
|
|
What is length (i.e. how is declared)?
|
|
|
|
|
I think the problem is the line before the one you've highlighted
try changing
open.read((char*) length, sizeof(short));
to
open.read((char*)(&length), sizeof(short));
System.IO.Path.IsPathRooted() does not behave as I would expect
|
|
|
|
|
|
No worries
What about this...
// Add a terminator
buf[4] = '\n';
usually you would terminate a string with '\0'
System.IO.Path.IsPathRooted() does not behave as I would expect
|
|
|
|
|
Oops... I'm just used to seeing that \n all the time... Thanks!
Windows Calculator told me I will die at 28.
|
|
|
|
|
Please suggest me any correction for this code.
This code is saving image in inverted format.
//This is for getting data from clipboard in CBitmap's object.
OpenClipboard();
Glb=EnumClipboardFormats(0);
HANDLE hBitMap = GetClipboardData(Glb); //getting from clipboard
if(hBitMap == NULL)
{
AfxMessageBox("Error in Capturing Image");
return;
}
//CBitmap * bmp = CBitmap::FromHandle(hBitMap);
CBitmap bmp;
if(!bmp.Attach((HBITMAP)hBitMap))
{
AfxMessageBox( "Error in Loading Image" );
}
BITMAP bitmap ;
bmp.GetBitmap(&bitmap);
int size = ((bitmap.bmWidth)*(bitmap.bmHeight)*(bitmap.bmBitsPixel))/8;
BYTE *lpBits = new BYTE[size];
::GetBitmapBits((HBITMAP)hBitMap,size,lpBits);
WriteBmp("C\\Patient.bmp",&bitmap,(int*)lpBits);
CloseClipboard();
}
For writing ang saving .bmp file.......
void WriteBmp(char* name,BITMAP *bmp,int* data)
{
BITMAPINFO Bmi;
memset(&Bmi,0,sizeof(BITMAPINFO));
Bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
Bmi.bmiHeader.biWidth = (bmp->bmWidth);
Bmi.bmiHeader.biHeight = (bmp->bmHeight);
Bmi.bmiHeader.biPlanes = 1;
Bmi.bmiHeader.biBitCount = bmp->bmBitsPixel;
Bmi.bmiHeader.biCompression = BI_RGB;
Bmi.bmiHeader.biSizeImage = bmp->bmHeight*bmp->bmWidth*bmp->bmBitsPixel/8;
FILE* image = fopen (name,"wb");
if(image==0)
return;
int h = abs(Bmi.bmiHeader.biHeight);
int w = abs(Bmi.bmiHeader.biWidth);
Bmi.bmiHeader.biHeight=h;
Bmi.bmiHeader.biWidth=w;
int sz = Bmi.bmiHeader.biSizeImage;
BITMAPFILEHEADER bfh;
bfh.bfType=('M'<<8)+('B');
bfh.bfOffBits=sizeof(BITMAPFILEHEADER)+ sizeof(BITMAPINFOHEADER);
bfh.bfSize=sz+bfh.bfOffBits;
bfh.bfReserved1=0;
bfh.bfReserved2=0;
fwrite(&bfh,sizeof(bfh),1,image);
fwrite(&Bmi.bmiHeader,sizeof(BITMAPINFOHEADER),1,image);
fwrite(data,sz,1,image);
fclose(image);
}
|
|
|
|