|
Hello,
In my program I dynamically create controls according to data read from a database. The control can be either CEdit or CComboBox. I also assign a unique control ID to each of the created controls (I know the ids).
Once controls created when a button pressed it's supposed to save controls values in the database.
Getting the text from the CEdit control isn't a problem as I just do GetDlgItemText(...). However, in case of the CComboBox I need to retrieve the ItemData using GetItemData. This is where I'm unsure of what to do.
I don't save anywhere if control with specific ID is a CComboBox or CEdit. Is is possible to know only by ID what kind of a control it is and to retrieve its original class?.
I was thinking just to make a struct:
struct {
CEdit *edit=NULL;
CComboBox *combo=NULL;
} myDynControls;
and then make an array of this struct. Each coresponding to an ID. I won't have more than 10 controls at a time.
What do you think? Is it a good idea? (i will delete everything after done working with ofcourse )
|
|
|
|
|
Hi Daredevil,
All MFC classes that derive from CObject (of which CWnd does) have a CRuntimeClass object associated with it.
So to see if your object is a CEdit control:
CWnd* pWndControl = m_arrMyControls[i];
if (pWndControl && pWnd->GetSafeHwnd())
{
CRuntimeClass* pClass = pWnd->GetRuntimeClass();
if (pClass)
{
CString strName = pClass->m_lpszClassName;
}
}
Hope this helps,
Andy
|
|
|
|
|
How about using IsKindOf() ?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi All,
Although the primary keys are working fine I am having terrible trouble getting the Index information.
Any ideas what I am doing wrong? Here is some code:
CIndexes rsIndex;
hResult = rsIndex.Open(m_session, NULL, NULL, NULL, tableData->sSchema, tableData->sName);
if(hResult == S_OK)
{
hResult = rsIndex.MoveNext();
while (hResult == S_OK) {
CString indexColumnName =
rsIndex.m_szColumnName;
indexes.Add(indexColumnName);
hResult = rsIndex.MoveNext();
}
}
I have tried it with 4 NULL's and not passing the schema name but it still gives me a zero record count.
Any ideas would be appreciated!
Thanks,
Chris
|
|
|
|
|
I developped a program to communicate on serial port com. It works fine on xp/W2000.
Then I wanted to include this into a bigger project, so I decided to change it into a dll. It works fine on W2000, but the same application using the same dll NEVER works on WXP. Does anybody have an idea about what could happen?
When I say it never works I mean that the thing that reiceives the data transferred on the serial link (I see the data transferred via a spy on the link) does'nt act as it really reiceived everything OK. I mean all the data are transferred, but it acts as if the flow was interrupted sometimes.
THANKS for your help!!!!
|
|
|
|
|
How can I add icon to main menu. (not use MFC).???
I have 2 files. First zasoby2.rc :
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
MOJEMENU MENU DISCARDABLE
BEGIN
POPUP "&Program"
BEGIN
MENUITEM "&Wyj?cie", IDM_WYJSCIE
END
POPUP "&Model"
BEGIN
MENUITEM "&Liniowy", IDM_LINIOWY
MENUITEM "&Nieliniowy", IDM_NIELINIOWY
MENUITEM "&Zerwanie", IDM_ZERWANIE
END
POPUP "&Pomoc"
BEGIN
MENUITEM "&O programie...", IDM_O_PROGRAMIE
END
END
Second menu1.h :
//zdefiniowane operacje menu
//#define IDM_NOWA 100
#define IDM_WYJSCIE 101
#define IDM_O_PROGRAMIE 102
#define IDM_LINIOWY 103
#define IDM_NIELINIOWY 104
#define IDM_ZERWANIE 105
//#define IDM_BLOKADA 106
#define IDI_IKONA1 210
#define IDI_IKONA2 220
#define IDI_IKONA3 230
#define IDI_IKONA4 240
//
#define IDC_MAIN_EDIT 111
#define IDC_MAIN_TOOL 112
What can I do ??
Please help!! Qdlaty
|
|
|
|
|
Hi,
I made a web browser using CHtmlView. it works perfactly. When i want to print a webpage it print with its own header & footer. I want to change these Header and Footer as i like.
If i get some help on this matter, it will relief a great pain.
Thanking you.
[Shumon]
|
|
|
|
|
I’m going to Serialize a class with CString and int-members to a file and then transfer it over the network. One of the members is a password-like one and I would like it to be encrypted before the serialization.
Any tip fore easy implementation.
...and justice for all
APe
|
|
|
|
|
|
HOW to Close the instance of application run by my COde..
if i have its HANDLE
????
thanx
|
|
|
|
|
That wont close anything.
I think he is saying how to kill an application started by his application when he has it's handle.
CloseHandle will close the Kernel handle - when the handles refrence count drops to 0, but wont actually close the spawnded process.
TerminateProcess() will very nastly kill a process given its handle.
|
|
|
|
|
Yes, you are right.
Guess I am being spontaneous.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Hi ,
How to get the contents of a folder from remote system in VC++ ?
The contents retrieved from the folder of remote system should be added to the listbox of our application.
Can anyone help me pls........
Raji
|
|
|
|
|
|
i want to get the contents of a shared folder of a remote system
Raji
|
|
|
|
|
The CFileFind class supports UNC so it can iterate remote folders as well as local folders. Something like:
CFileFind ff;
BOOL bFound = ff.FindFile("\\\\server\\share\\users\\davidc\\*.*");
do
{
bFound = ff.FindNextFile();
TRACE("%s\n", ff.GetFilePath());
} while (bFound != FALSE);
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi ,
How to create a movable bar/line on a picture box using VC++?
Aparna
|
|
|
|
|
Look for MFC CRectTracker.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Hi,
I included this file in my source code and depsite this it throws error.
I am ruunng on Windows 2000 PROFESSIONAL.
Looks strange.
Psl helpme out.This is the source code available from MSDN.
//#include "windows.h" header file"
#include <windows.h>
//#include "stdio.h" header file
#include <stdio.h>
//#include "tchar.h" header file
#include <tchar.h>
//#include "iphlpapi.h" header file
#include <iphlpapi.h>
int main()
{
HRESULT hr;
IPAddr ipAddr;
ULONG pulMac[2];
ULONG ulLen;
ipAddr = inet_addr ("192.168.25.31");
memset (pulMac, 0xff, sizeof (pulMac));
ulLen = 6;
hr = SendARP (ipAddr, 0, pulMac, &ulLen);
printf ("Return %08x, length %8d\n", hr, ulLen);
size_t i, j;
char * szMac = new char[ulLen*3];
PBYTE pbHexMac = (PBYTE) pulMac;
//
// Convert the binary MAC address into human-readable
//
for (i = 0, j = 0; i < ulLen - 1; ++i) {
j += sprintf (szMac + j, "%02X:", pbHexMac[i]);
}
sprintf (szMac + j, "%02X", pbHexMac[i]);
printf ("MAC address %s\n", szMac);
delete [] szMac;
return 0;
}
after compiling:
Error :\kuttanur\macaddress\mac.cpp(5) : fatal error C1083: Cannot open include file: 'iphlpapi.h': No such file or directory
Regards
|
|
|
|
|
Have you installed the Platform SDK? If not then I recommend you install it.
If you have ensure that the appropriate path is in you include directory list. i.e. <platform sdk directory>\include
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? - David Williams (Little Britain)
|
|
|
|
|
Ya ANTONY ,Its already installed.
I have run many window programs even
getting the list of network resourcesWhen I wrote a smll program in Win32.
All r running well excep this.
Can somebody help me out.
Regards
BlackTiger
BlackTiger007
|
|
|
|
|
If you search for iphlpapi.h on your system is it in a directory that is in your include list?
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? - David Williams (Little Britain)
|
|
|
|
|
Antony,
When I searched the file
I found it 2 locations
1. C:\Program Files\Platform SDK\Include
2. C:\Program Files\Microsodt Visual Studio.net 2003\Vc7\PlatformSDK\Include
But I am running this application using VC 6.0.
Regards
BlackTiger007
BlackTiger007
|
|
|
|
|
Antony,
The file is missing in VC 6.0 .
Whereas the same program runs very well in Visual Studio.net
Thanks Antony
Bye
|
|
|
|
|
You need to ensure that C:\Program Files\Platform SDK\Include is being searched. Go to Tools/Options and select the Directories tab. Is C:\Program Files\Platform SDK\Include in the list of Include directories?
You can also right click on the #include <iphlpapi.h> statement and select Open. If the file does not open, you know that it cannot be found.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|