|
The answer is quite simple.
What you are doing here is calling CWnd::CreateEx , that allows you to create child windows. However, there is a function call CComboBox::Create that will create a combo box control and attach it to the CComboBox object.
The calling convention for Create is a bit different, as you only need to supply the standard flags, rectangle, pointer to parent CWnd and the ID. This call doesn't allow you to specify extended window flags. But you can use GetExStyle , a bit mask and SetWindowLong to set the client edge extended style.
Another reason why it creates an edit box might be because of the ES_NUMBER flag. This flag is meant for edit controls, not comboboxes. All combobox flags start with CBS_ prefix. Try removing it and see what happens.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
How about:
CComboBox m_schemaCombo;
m_schemaCombo.Create(WS_CHILDWINDOW | WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWN,
CRect(row3,
frameTop + 3 * topBottomOffset + buttonHeight3,
editBoxWidth,
frameTop + 3 * topBottomOffset + buttonHeight2 + buttonHeight2),
this, IDC_SCHEMA_COMBO);
m_schemaCombo.SetFont(GetFont());
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Thanks David....It worked.
|
|
|
|
|
I am on XP and I have created an overlapped mode pipe. I call ConnectNamedPipe and set the event on wait in WaitForSingleObject. Problem comes when the WaitForSingleObject times out in release mode compile. Any other call to the pipe handle on which no client connects and connection time out throws some exception in release mode . It all works fine in debug mode.
<br />
OVERLAPPED op;<br />
op.hEvent = CreateEvent(....<br />
HANDLE hPipe = ConnectNamedPipe(....<br />
<br />
switch(WaitForSingleObject(op.hEvent, 5000)<br />
{<br />
case WAIT_OBJECT_0:<br />
...
CloseHandle(hPipe);
<br />
case WAIT_TIMOUT:<br />
...
CloseHandle(hPipe);
}<br />
PS: every thing works fine in Debug mode...Exceptions come in on release mode
Atif
|
|
|
|
|
Hi there
Im sorry because this is not realy a VC++ Question and its maybe the wrong forum...but here i am
Does anyone knows some ressources/manuals (e.g. URL's, PDF's, ...) of how a normal bitmap is build/written? -> If possible - the newbie way
I need to write code which "writes" a bitmap to a file - but i cant use librarys or the win32/mfc/... methods for doing this
Thanks for reading
--------------------
select *
from users
where
iq > 60;
0 rows returned.
|
|
|
|
|
Hi,
a bmp consists of a header and a colordefinition of each pixel. (so you get a header and a matrix of colors)
you can write the bmp bytewise with fwrite I think. just make sure the header is correct AND write the colors BACKWARDS (BGR instead of RGB). (one color is three bytes, no?)
a little help: open a bmp with a hex-editor. you'll see what I mean.
Hope this helps (a little )
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
A Beginners Guide to Bitmaps[^]
and
Bitmaps and Palette Manipulation[^]
are just a couple of randomly picked examples when you use Google and search for Bitmaps!
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Oh the google way
Thanks both of you
|
|
|
|
|
I tried to make a project with one Document and 2 views. But I had a problem - i can't switch between them. How to do it?
In InitInstance i did this:
CSingleDocTemplate* pDocTemplate;
CSingleDocTemplate* pDocTemplate1;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CSDIMultiViewDoc),
RUNTIME_CLASS(CMainFrame),
RUNTIME_CLASS(CSDIMultiViewView));
AddDocTemplate(pDocTemplate);
pDocTemplate1 = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CSDIMultiViewDoc),
RUNTIME_CLASS(CMainFrame),
RUNTIME_CLASS(CSDIMultiViewListView));
AddDocTemplate(pDocTemplate1);
|
|
|
|
|
|
|
Hi !
Here is a coding design question.
I defined a class in my application, let's call it CPoint.
In many other classes of my application, I have to manipulate lists of pointeurs on CPoint objects. I need to pass such lists by parameters.
For now, I defined, in each class using a list of CPoint a typedef like this :
typedef vector<CPoint*> PointList_t;
I'm now wondering if, instead of declaring such typedef in each class using a list of CPoint*, if it would be better coding practice to define such typedef in the CPoint class itselt :
class CPoint
{
public:
typedef vector<CPoint*> PointList_t;
...
};
and, in classes using a list of CPoint*, I would do (for example) :
void Foo(CPoint::PointList_t MyPointList)
{
CPoint::PointList_t::iterator It = MyPointList.begin();
...
...
}
The advantage of this new way of doing would be to avoid multiple declaration of the same typedef, the drawback is that I have to put CPoint:: each time I need a PointList_t and that I have to include the CPoint.h in the header of the classes using such typedef where a simple declaration of the class was enough with my first way of doing things.
What is your suggestion ?
Thanks !
Jerome
|
|
|
|
|
I would always put the typedef where it fits best. In your example the best fit is within the CPoint class.
This way as you have stated it is defined only once. This also means that there is one point of maintenance.
IMO the drawbacks you have stated are not really drawbacks, just a little more typing!
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
I have been trying to define a structure and use it with a union, but the bit fields seem to cause the structure to be bigger than I expected.
e.g. ( 4 x 4 bit fileds + 2 float fields + short = 11 bytes)
But what I get is 28 bytes.
typedef struct <br />
{<br />
unsigned data : 4 ; <br />
}W03_SECOND_10_S_;<br />
<br />
typedef struct <br />
{<br />
unsigned data : 4 ; <br />
}W03_SECOND_1_S_;<br />
<br />
typedef struct <br />
{<br />
unsigned data : 4 ; <br />
}W03_SECOND_0_1_S_;<br />
<br />
typedef struct <br />
{<br />
unsigned data : 4 ; <br />
}W03_SECOND_0_01_S_;<br />
<br />
typedef struct <br />
{<br />
float data; <br />
}W05_PRICE;<br />
<br />
typedef struct <br />
{<br />
float data; <br />
}W07_NETCOST;<br />
<br />
typedef struct <br />
{<br />
unsigned short data; <br />
}W08_INDEX;<br />
typedef struct{<br />
W03_SECOND_10_S_ w03_second_10_s_;<br />
W03_SECOND_1_S_ w03_second_1_s_;<br />
W03_SECOND_0_1_S_ w03_second_0_1_s_;<br />
W03_SECOND_0_01_S_ w03_second_0_01_s_;<br />
W05_PRICE w05_price;<br />
W07_NETCOST w07_netCost;<br />
W08_INDEX w08_index;<br />
}TEST1_10;
union<br />
{<br />
TEST1_10 message_data;
unsigned short buffer[32];
}messageStructData;<br />
<br />
int sizeStruct = sizeof(messageStructData);
The size if 64 bytes, but the size of the TEST1_10 structure is 28 bytes (not 11 bytes)so each field of 4 bits is taking up 4 bytes
TEST1_10 message_data1;<br />
int sizeStruct1 = sizeof(message_data1);
sizeStruct1 = 28 bytes.
The short is being padded to 4 bytes as is each 4 bit field.
Is it possible to map bit fields onto a structure and then a union in C++.
|
|
|
|
|
The best you will get is to set the byte alignment for structures to a single byte. Currently you must have it set to 4 bytes.
Look in the Project Settings under Code Generation
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Thanks for your post, I set it to 1 byte and that reduced the count from 28 to 26.
Are they no way that I can used bit fields in the way I intended; i.e.
overlay these bit field and other fileds (short, float etc) with a buffer.
I did remove the wrapping of the bit fields from a struct:
typedef struct{<br />
unsigned data1 : 4 ; <br />
unsigned data2 : 4 ; <br />
unsigned data3 : 4 ; <br />
unsigned data4 : 4 ; <br />
W05_PRICE w05_price;<br />
W07_NETCOST w07_netCost;<br />
W08_INDEX w08_index;<br />
}TEST1_10;
this gave a size of 14 (2 floats, 1 short and 4 x 4 bit fields = 11 bytes)
But each 4 bit field is taking a byte; hence 14 bytes.
Any suggestions to get this scheme working?
|
|
|
|
|
Without combining the fields in the struct I can not see how you can do this.
e.g.
typedef struct{<br />
BYTE data1and2; <br />
BYTE data3and4;<br />
W05_PRICE w05_price;<br />
W07_NETCOST w07_netCost;<br />
W08_INDEX w08_index;<br />
}TEST1_10;
Downside is that will have to do the bit manipulation on data1and2 and data3and4 in order to get the appropriate 4bit values however. Though a couple of functions should be enough to get and set the values.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Contrast what you have with:
#pragma pack(1)
typedef struct
{
unsigned data1 : 4;
unsigned data2 : 4;
unsigned data3 : 4;
unsigned data4 : 4;
float data5;
float data6;
unsigned short data7;
} TEST1_10;
#pragma pack()
TEST1_10 message_data1;
int sizeStruct1 = sizeof(message_data1); What is the value of sizeStruct1 ?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
The size of the structure is 14 bytes.
I assume this is (8 for 2 floats + 2 for the short and 4 for the 4 bit fields)
I am after a size of 11 bytes.
Are they any settings that I have not made?
|
|
|
|
|
You do know that sizeof() cannot be used on bit fields, don't you?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
If I use the following code:-
typedef struct<br />
{ <br />
unsigned short data1;<br />
float data5;<br />
float data6;<br />
unsigned short data7;<br />
}TEST1_101;<br />
#pragma pack()<br />
TEST1_101 message_data1;<br />
int sizeStruct1 = sizeof(message_data1 );
I get size = 12 bytes, which I understand (8 for floats + 2 x 2 for shorts = 12 bytes. But why dont I get 12 for the following:-
typedef struct<br />
{ <br />
unsigned data1 : 4;<br />
unsigned data2 : 4;<br />
unsigned data3 : 4;<br />
unsigned data4 : 4;<br />
float data5;<br />
float data6;<br />
unsigned short data7;<br />
}TEST1_101;<br />
#pragma pack()<br />
TEST1_101 message_data1;<br />
int sizeStruct1 = sizeof(message_data1);
|
|
|
|
|
sweep123 wrote:
But why dont I get 12 for the following:-
I hinted at the fact that you cannot use sizeof() with bit fields. Did you miss that earlier?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
OK, yes I saw your post that stated that, but removed the bit fields and tried a few other things and then put back the bit fields.
I think the overlay works with the union, but the fact that a bug in my program and the sizeof() problem with bitfields led to confusion.
Thanks,
|
|
|
|
|
Hi, I'm having a problem with a dialog. I need my dialog box to recieve/intercept all keyboard events that go on inside, but I'm getting problems where only the controls are reciving the keyboard events. Presumably only the window with the focus can ever recieve keyboard message. My dialog simply does not recieive any OnChar, OnKeyDown, or OnSysChar events. So I implemented OnKillFocus in the dialog like so...
void CMyDialog::OnKillFocus(CWnd* pNewWnd)
{
CWnd::OnKillFocus(pNewWnd);
SetFocus();
} However this seems to make all my buttons totally unclickable! Does anyone have a solution to this at all?
Joel Holdsworth
|
|
|
|
|
You might want to try overriding PreTranslateMessage for your dialog.
|
|
|
|