|
I just did what you described, and had no trouble. It behaved as expected. So something else in your application is giving you trouble.
Are these just CComboBoxes? Or CMyCustomCombo?
Does it work on a freshly created dialog app project? If so, what are you doing differently?
Are you handling some fancy CBN_MEASURESTUFF notification and doing odd sums?
I'm just guessing now...
Iain.
Iain Clarke appearing in spite of being begged not to by CPallini.
|
|
|
|
|
Hi Iain
No, it is just a normal combo. Not handling anything. Very strange! I've tried it on two different machines (reproducing my steps) and get exaclty the same thing.
I've given the combo a variable i.e. m_comboBox and fill it using
m_comboBox.AddString(_T("Hello World")); etc
Is there any code in particular I could cut and paste to show what I've done?
Paul
|
|
|
|
|
Here's a copy of the resource:
IDD_DIALOG1 DIALOGEX 0, 0, 186, 90
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "My First Dialog"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,129,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,129,24,50,14
CONTROL "Radio1",IDC_RADIO1,"Button",BS_AUTORADIOBUTTON,21,14,38,10
COMBOBOX IDC_COMBO2,22,39,57,14,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
END
|
|
|
|
|
I just peeked at my resource, and I got:
COMBOBOX IDM_TOOLS_MEASUREMENTANGLE,36,8,60,116,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
There are two differences: CBS_SORT, which we can ignore, but I almost never use, and the cy value.
You have 22,39,57,14 and I have 36,8,60,116. Try editing yours to be a medium value (eg) 80, and see how you get on.
Your may be so small, windows is going "With the edit box, I can't even see one drop down. I'd better just show the lot". That would be a surprise, but not a shock. Probably some fix to be compatible with a program under Windows 3.0.
Iain.
Iain Clarke appearing in spite of being begged not to by CPallini.
|
|
|
|
|
Hi Iain
I tried your suggestion and still no luck. Very strange! This was done on VS 2008 but I get exactly the same thing in Visual Studio 2005.
Here's my dialog code:
// TestDialog.cpp : implementation file
//
#include "stdafx.h"
#include "mfc2008combodroplist.h"
#include "TestDialog.h"
// TestDialog dialog
IMPLEMENT_DYNAMIC(TestDialog, CDialog)
TestDialog::TestDialog(CWnd* pParent /*=NULL*/)
: CDialog(TestDialog::IDD, pParent)
{
}
TestDialog::~TestDialog()
{
}
void TestDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_COMBO1, m_comboBox);
}
BEGIN_MESSAGE_MAP(TestDialog, CDialog)
END_MESSAGE_MAP()
// TestDialog message handlers
BOOL TestDialog::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_comboBox.AddString(_T("A"));
m_comboBox.AddString(_T("A"));
m_comboBox.AddString(_T("A"));
m_comboBox.AddString(_T("G"));
m_comboBox.AddString(_T("A"));
m_comboBox.AddString(_T("A"));
m_comboBox.AddString(_T("D"));
m_comboBox.AddString(_T("A"));
m_comboBox.AddString(_T("G"));
m_comboBox.AddString(_T("A"));
m_comboBox.AddString(_T("A"));
m_comboBox.AddString(_T("A"));
m_comboBox.AddString(_T("A"));
m_comboBox.AddString(_T("G"));
m_comboBox.AddString(_T("A"));
m_comboBox.AddString(_T("A"));
m_comboBox.AddString(_T("D"));
m_comboBox.AddString(_T("A"));
m_comboBox.AddString(_T("G"));
m_comboBox.AddString(_T("A"));
m_comboBox.AddString(_T("A"));
m_comboBox.AddString(_T("A"));
m_comboBox.AddString(_T("A"));
m_comboBox.AddString(_T("G"));
m_comboBox.AddString(_T("A"));
m_comboBox.AddString(_T("A"));
m_comboBox.AddString(_T("D"));
m_comboBox.AddString(_T("A"));
m_comboBox.AddString(_T("G"));
m_comboBox.AddString(_T("A"));
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
and the header:
#pragma once
#include "afxwin.h"
// TestDialog dialog
class TestDialog : public CDialog
{
DECLARE_DYNAMIC(TestDialog)
public:
TestDialog(CWnd* pParent = NULL); // standard constructor
virtual ~TestDialog();
// Dialog Data
enum { IDD = IDD_DIALOG1 };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
public:
CComboBox m_comboBox;
virtual BOOL OnInitDialog();
};
|
|
|
|
|
Ah, I tried adding loads and loads of entries, so that the list won't fit on the screen and a scrollbar appears!
However, this isn't what I want. Obviously when the list box size is set in the resource editor the whole point is that it shouldn't be any bigger than intended.
I'm very puzzled but very grateful for the help your giving!
Paul
|
|
|
|
|
I made a virgin project, added a box, and it worked as we'd both expect. If you email me your address, I can zip it and send it. (Obviously don;t post it here). It is a VC6 project though. Which made me look at your post again, and I saw...
the line "#include "mfc2008combodroplist.h", makes me suspicious...
Maybe MFC is being naughtily helpful?
Are you under Vista, and it's being "helpful" too?
Have you tried editing the resource as I recommended and setting the CY value as something medium? (ie, well above 14!)
Iain.
Iain Clarke appearing in spite of being begged not to by CPallini.
|
|
|
|
|
Hi Iain
The include is merely the name I gave the application. I don't think it has anything to do with it because I had a different name on the Visual Studio 2005 version.
I'm using XP and Vista. The problem is on both.
Yep, I changed the CY value without any luck.
This is a strange one!!!!
Paul
p.s. I've sent you an email
|
|
|
|
|
Hi Iain
I've just tried to do the same thing in VC++ 6 and it works!!!
This is obviously an issue with VS2005!
I'm amazed there aren't more posts on the issue though. Surely others have encountered it!!!
Paul
|
|
|
|
|
HOWEVER - when I load the VC++ 6 project into Visual Studio 2005 it WORKS!!!
Paul
|
|
|
|
|
My bet is that it's a difference MCF'S combobox. I bet MFC v2005 is doing clever things - and the imported project is using mfc42.dll.
Try not using CComboBox as a member variable and DDX_Controlling.
Try using SendDlgItemMessage (CB_ADDSTRING.... etc)
Iain.
Iain Clarke appearing in spite of being begged not to by CPallini.
|
|
|
|
|
that's sounds sensible to me!
I'll give it a go and post if it works.
It does sound like a bug though doesn't it?
Paul
|
|
|
|
|
Hi Iain
I'm afraid I did't make much progress with your suggestion using SendMessage i.e. deadlines etc. However, I would like to thank you again for all your hard work in helping me with this problem.
Paul
|
|
|
|
|
Davros wrote: That is, it simply drops down with all the entries.
If all of the items are there, what's the problem?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
lol - well, because (1) the code isn't doing what it should and (2) you get list box which extends a large area and looks ugly.
(1) is the most important thing you - don't you agree?
|
|
|
|
|
Hi all,
I have a project to be done by this week!! i have a fingerprint censor from which i have to access the finger print data. Hoew do i access that data from that device. Drivers for the device is installed and can anybody help me to find some links and tutorials for accessing Hardware in MFC???
Please help me with some useful stuffs...
Thanks in advance
||SnAkeBed||
|
|
|
|
|
One key piece of information that may help people to help you is - how is the scanner attached to your PC, Serial cable, USB, FireWire, VMEBus, Bluetooth, WLAN 802.11.g &c
Once we've got that figured out I'd almost certainly suggest not writing the device communications stuff directly into your MFC app. Create a separate plain C++ Dll and possibly a stand alone test app to load it up and give it some exercise.
If you end up having to write a driver for your device remember there's a whole Driver Development Kit you can download from Microsoft with sample code and the like. Standards documents are also useful if you're dealing with a device that has to conform to some spec like USB or Ethernet.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
hi,
Thanks for ur reply
Its a USB Device and the driver for the device is already installed.so i think there is no need of writing a seperate driver for that.
Since i'm new to this subject can u please help me in providing some links for accessing a USB device
Thanks in advance
||SnAkeBed||
|
|
|
|
|
The way to work with USB devices is to first get the handle to the driver by calling the CreateFile functions. Once you have the handle, you can start exchanging data with the device by calling ReadFile and WriteFile (passing the handle). You can also exchange specific IO control codes with the driver by calling DeviceIOControl.
That's from a high level overview. You should have received documentation with the driver itself describing how to use it the driver (what are the IO control codes you can exchange with it, which name you need to pass to the CreateFile function in order to retrieve the handle of the driver, ...).
|
|
|
|
|
|
Where does that device come from ? Don't you have any driver supplied with it ? Any documentation that comes with the sensor ?
SnaKeBeD wrote: help me to find some links and tutorials for accessing Hardware in MFC
You almost never access hardware directly, except for things like devices connected to the serial port, but then the protocol is vendor specific and you won't find any generic tutorial.
|
|
|
|
|
hi
Thank you for ur kind reply.
There will be some way like accessing a camera with the default driver installed in the machine. I want something similar to that!!!!
||SnAkeBed||
|
|
|
|
|
drivers for that USB device is alrady installed
||SnAkeBed||
|
|
|
|
|
Then look on the website for the company that makes the scanner. They'll probably have documentation.
It's also possible that it acts just like an A4 scanner, only little and higher resolution.
In which case, maybe the driver comes with a TWAIN interface? I'm no expert on that.
Can you capture images using (eg) Photoshop? Did it come with applications?
Iain.
Iain Clarke appearing in spite of being begged not to by CPallini.
|
|
|
|
|
Hi,
I am creating a Winword document from a C++/MFC program and I need to lock the document so that the user can't change it afterwards. I have used the following code but it doesnt work. Anyone have any ideas what I am doing wrong?
TIA
Documents oDocs;
//Optional param
COleVariant vOpt(DISP_E_PARAMNOTFOUND, VT_ERROR);
oDocs = m_wordApp.GetDocuments();
m_document = oDocs.Add(vOpt, vOpt, vOpt, vOpt);
m_document.Activate();
// Then later...
COleVariant pw(pszPassword);
VARIANT v;
VariantClear(&v);
v.vt = VT_BOOL;
v.boolVal = FALSE;
// wdAllowOnlyReading appers to have a value 3 so thats what I use
m_document.Protect(3, &v, pw);
|
|
|
|