|
I need to configure some application variables. I have a CFormView and via menu conmstruct a simple CDialog. However, after DoModal returns TDOK I am unable to retrieve the CComboBox selection - not even the GetCount returns number of items in the CComboBox. I seldom use CDialog but this got me stumped, I am obviously missing an important piece of code.
Thanks for reading and your help is as always appreciated.
Here is the offending code:
void CFD2008View::OnConfigureSetup()
{
CString strText;
CComboBox* pCombo10;
int nIndex;
int nCount;
// verify document
if(!m_CFD2008Doc)
m_CFD2008Doc = GetDocument();
VERIFY (m_CFD2008Doc);
CDialog dlg(IDD_DIALOG1);
if (dlg.DoModal()==IDOK){
TRACE("\nvoid CFD2008View::OnConfigureSetup() ");
pCombo10 = (CComboBox *) GetDlgItem(IDC_COMBO10);
VERIFY(pCombo10);
nIndex = pCombo10->GetCurSel();
//always returns 0
nCount = pCombo10->GetCount();
// always returns 0
}
}
|
|
|
|
|
Try using
pCombo10 = (CComboBox *) dlg.GetDlgItem(IDC_COMBO10);
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
When DoModal returns, the dialog box window (and combo box) have been destroyed, so attempting to access them won't work.
Instead, you could pass a pointer to the CFD2008View into the dialog - one way is
CDialog dlg(IDD_DIALOG1);
dlg.m_pView = this;
if (dlg.DoModal()... Of course, you need to define a member variable in the dialog to hold this pointer (m_pView). Then in the view class, add member variables for the information you're trying to get. Now in the dialog's OnOK function, set the view class variable so they contain the desired information.
Note that getting the count, or a pointer to the combo box will be useless as it's going to be destroyed. If you need to know the value of a selected combo box items, you'll need to find that value in the dialog's OnOK, and set that value into the view class.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Thanks guys. I used both of yours advices and came up with this.
X_ConfigureDialog dlg; // derived from CDialog with IDD_DIALOG1 resource;
if (dlg.DoModal()==IDOK){
// pass dialog data to current view
// or use directly in current view
m_strBand = dlg.m_ComboBox10;
m_strMode = dlg.m_ComboBox20;
}
Conclusion
1. Do not use CDialog "directly" as local variable.
2. Derive view class variable from CDialog - I guess I should have known that.
3. Let DDX/DDV do its stuff - when DoModal completes.
It still puzzles me why dlg is valid when used as derived class. I guess MFC / C++ class hierary magic.
Thanks Vaclav
|
|
|
|
|
Hey,
When obtaining a key to decrypt a file encrypted using RC4 algorithm, CryptImportKey() fails.
The error says, "Invalid type specified".
What may be the possible reasons for this ?
It fails when I export the key in one application and import it in another application.
Has this something to do with storage of keyBLOB (I store it in a text file while exporting the key and read it from the text file while importing from a different application)?
Or is there some other reason that may lead it to failure.
Please reply at the earliest.....
Regards,
|
|
|
|
|
hi..
can i connect to the internet through c?
i prepared an application but am stuck up with the actual headers to be used..
please help
custom website design
modified on Friday, June 19, 2009 5:17 AM
|
|
|
|
|
Using internet means what? Even sending a file across n/w would mean "using internet".
----------------------------
286? WOWW!
|
|
|
|
|
C can do anything u tell it to do!!! it is probably the language that is in control of any bit of hardware u look at today.
here is a good embedded stack that is scaleable and will make your toaster TCP/IP compatible
http://www.sics.se/~adam/uip/index.php/Main_Page[^]
|
|
|
|
|
Use WinInet[^] - that's the Microsoft internet library that's C compatible that I'd use.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
thanks a ton for this.. i wanted this..
thanksssssssssssssssssssssssssss
|
|
|
|
|
If I define the constructor of typedef struct, it will appear some error(error C4430,errorC4183). How do I solve this problem?
struct b
{
b()
{
}
b(int p1)
{
m_p1=p1;
}
int m_p1;
};
typedef struct
{
a()
{
}
a(int p1)
{
m_p1=p1;
}
int m_p1;
}a;
1>d:\windowsxpdoc\visual studio 2008\projects\t3\t3\t3dlg.cpp(156) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\windowsxpdoc\visual studio 2008\projects\t3\t3\t3dlg.cpp(158) : warning C4183: 'a': missing return type; assumed to be a member function returning 'int'
1>d:\windowsxpdoc\visual studio 2008\projects\t3\t3\t3dlg.cpp(161) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\windowsxpdoc\visual studio 2008\projects\t3\t3\t3dlg.cpp(163) : warning C4183: 'a': missing return type; assumed to be a member function returning 'int'
|
|
|
|
|
the type was named but struct wasn't.
typedef struct a
{
a()
{
}
a(int p1)
{
m_p1=p1;
}
int m_p1;
} aType;
|
|
|
|
|
Hi,
I need to capture the image from a window into a CBitmap. The code I have written just produces a black bitmap (correct size though )
Can anyone see what I have done wrong? The bimap is created with the correct bits/pixel (32).
CRect rect(0, 0, 100, 100);
CBitmap bmpCap;
CBitmap *pBmpOld = NULL;
CWnd* pWnd = GetDlgItem(IDC_SUCN_CHART);
pWnd->GetWindowRect(&rect);
ScreenToClient(rect);
CDC* pdcScreen = pWnd->GetDC();
CDC memDC;
BOOL bResult = memDC.CreateCompatibleDC(pdcScreen);
bResult = bmpCap.CreateCompatibleBitmap(pdcScreen, rect.Width(), rect.Height());
BITMAP bm;
bmpCap.GetBitmap(&bm);
pBmpOld = memDC.SelectObject(&bmpCap);
bResult = memDC.BitBlt( 0, 0, rect.Width(), rect.Height(), pdcScreen, rect.left, rect.top, SRCCOPY );
|
|
|
|
|
Hi,
You can call CWnd::PrintClient[^] and ask the window to draw itself into the destination device context.
CBitmap bmpCap;
CBitmap *pBmpOld = NULL;
CWnd* pWnd = GetDlgItem(IDC_SUCN_CHART);
pWnd->GetWindowRect(&rect);
ScreenToClient(rect);
CDC* pdcScreen = pWnd->GetDC();
CDC memDC;
memDC.CreateCompatibleDC(pdcScreen);
bmpCap.CreateCompatibleBitmap(pdcScreen, rect.Width(), rect.Height());
pBmpOld = memDC.SelectObject(&bmpCap);
pWnd->PrintClient(&memDC,PRF_NONCLIENT|PRF_CHILDREN);
memDC.SelectObject(pBmpOld);
pWnd->ReleaseDC(pdcScreen);
bmpCap.DeleteObject();
memDC.DeleteDC();
|
|
|
|
|
Wow thats cool
It looks like my problem was selecting the bitmap into the printer DC because it was not compatible. Using CWnd::PrintClient() should get me around this problem and its less code.
Thanks again, you have saved me hour of work trying to get thie code working.
|
|
|
|
|
Can someone help. I am not sure but I think i read about this before. I can't find it when I need it.
I am looking for anything that will help me compare 2 images of diferent sizes using VC++.
The following only tell me the sizes are different. However I already know that they are different.
BYTE image1[ImageSize];
BYTE image2[ImageSize];
if( memcmp(image1,image2,sizeof(image1)) == 0)
else
Thanks a million
|
|
|
|
|
Hi Fish,
The real question is how much accuracy do you require. If I wanted a quick and dirty image compare I would probably create a histogram of the colors[^] in both images. If you need greater accuracy then maybe you could use a library specifically designed for computer vision.
Integrating Vision Toolkit[^]
VLFeat[^]
Best Wishes,
-David Delaune
|
|
|
|
|
|
I have various Processes that are used in many of my programs. I want to put those Processes into "dills" so that I can load those dills when the User selects one in a program. This would illuminate the need to re-create the same processes in each program. The dills would need to contain it's own resources since they contain dialogs(the processes) and the program would not know in advance the resources. Is this possible? If so are there any tutorials on this subject using MFC?
Thanks in advance.
A C++ programming language novice, but striving to learn
|
|
|
|
|
|
I checked out some DILL articles. Nowhere is it explained whether a DILL can contain it's own resources. Can someone explain whether your DILL can contain Dialogs; and if so how can this be provided for linkage in a program.?
Since I don't know C#, or use the #include <windows.h> (because I use MFC exclusively), the articles you provided are useless to me. Thanks anyway.
A C++ programming language novice, but striving to learn
|
|
|
|
|
Larry Mills Sr wrote: I checked out some DILL articles. Nowhere is it explained whether a DILL can contain it's own resources. Can someone explain whether your DILL can contain Dialogs; and if so how can this be provided for linkage in a program.?
Absolutely, you can add dialogs to a resource DLL. In fact a DLL doesn't even need to have code, it can contain resources only.
Creating a Resource-Only DLL[^]
Codeproject Resource-Only DLL[^]
Larry Mills Sr wrote: Since I don't know C#, or use the #include <windows.h> (because I use MFC exclusively), the articles you provided are useless to me. Thanks anyway.
I should have been more specific, I will try harder in the future. Let me see if I can find a C++ plugin framework that will work with MFC using the link I provided:
http://www.codeproject.com/info/search.aspx?artkw=plugin[^]
Oh wow... the first link goes to a cross-platform plugin implementation:
DynObj - C++ Cross Platform Plugin Objects[^]
The third link goes to a Win32 implementation and it looks like its using mostly ISO standards.
There are many other pages in my codeproject search, I am starting to believe that maybe you didn't even take the time to look.
Btw, you can use the 'Advanced filter' at the top to filter out C# and other language/platform articles.
Best Wishes,
-David Delaune
|
|
|
|
|
Any idea why this code doesn't compile?
#include "stdafx.h"
#include <bitset>
#include <iostream>
#include <ctime>
using namespace System;
int main(array<System::String ^> ^args)
{
const int N = 2000000;
clock_t cstart = clock();
bitset<N + 1> b;
int count = 0;
int i;
for (i = 2; i <= N; i++)
b.set(i);
i = 2;
while (i * i <= N)
{
if (b.test(i))
{
count++;
int k = 2 * i;
while (k <= N)
{
b.reset(k);
k += i;
}
}
i++;
}
while (i <= N)
{
if (b.test(i)) count++;
i++;
}
clock_t cend = clock();
double millis = 1000.0 * (cend - cstart) / CLOCKS_PER_SEC;
cout << count << " primes \n" << millis << " milliseconds\n";
return 0;
}
Errors:
Error 4 error C2065: 'b' : undeclared identifier c:\Users\Administrator\Documents\Visual Studio 2008\Projects\SieveOfErathostenes\SieveOfErathostenes\SieveOfErathostenes.cpp 19 SieveOfErathostenes
Error 5 error C2228: left of '.set' must have class/struct/union c:\Users\Administrator\Documents\Visual Studio 2008\Projects\SieveOfErathostenes\SieveOfErathostenes\SieveOfErathostenes.cpp 19 SieveOfErathostenes
Error 6 error C2065: 'b' : undeclared identifier c:\Users\Administrator\Documents\Visual Studio 2008\Projects\SieveOfErathostenes\SieveOfErathostenes\SieveOfErathostenes.cpp 24 SieveOfErathostenes
Error 7 error C2228: left of '.test' must have class/struct/union c:\Users\Administrator\Documents\Visual Studio 2008\Projects\SieveOfErathostenes\SieveOfErathostenes\SieveOfErathostenes.cpp 24 SieveOfErathostenes
Error 8 error C2065: 'b' : undeclared identifier c:\Users\Administrator\Documents\Visual Studio 2008\Projects\SieveOfErathostenes\SieveOfErathostenes\SieveOfErathostenes.cpp 30 SieveOfErathostenes
Error 9 error C2228: left of '.reset' must have class/struct/union c:\Users\Administrator\Documents\Visual Studio 2008\Projects\SieveOfErathostenes\SieveOfErathostenes\SieveOfErathostenes.cpp 30 SieveOfErathostenes
Error 10 error C2065: 'b' : undeclared identifier c:\Users\Administrator\Documents\Visual Studio 2008\Projects\SieveOfErathostenes\SieveOfErathostenes\SieveOfErathostenes.cpp 39 SieveOfErathostenes
Error 11 error C2228: left of '.test' must have class/struct/union c:\Users\Administrator\Documents\Visual Studio 2008\Projects\SieveOfErathostenes\SieveOfErathostenes\SieveOfErathostenes.cpp 39 SieveOfErathostenes
Error 12 error C2065: 'cout' : undeclared identifier c:\Users\Administrator\Documents\Visual Studio 2008\Projects\SieveOfErathostenes\SieveOfErathostenes\SieveOfErathostenes.cpp 46 SieveOfErathostenes
NOTE:
1. Core Java Vol I 8th Ed. Pg. 713 (727)
Jon
|
|
|
|
|
Probably you get errors because are in the wrong forum (better luck here [^], maybe).
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]
|
|
|
|
|
The first error I get is this:
a.cpp(14) : error C2065: 'bitset' : undeclared identifier
This is because you use bitset without prefixing it with std:: , which is the namespace it lives in. Similarly, cout needs a std:: prefix, because that's where it lives.
[edit]Fix those two, and your code compiles fine. It runs as well.[/edit]
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|