|
|
Hello,
I have a combobox on my dialog and the dialog is created without resources.
Now I want to decide the width of the combo box depending upon the number characters that would appeaar in any combo box.
If I decide according to the font size of the combo box then for some sizes the size of the combo box is right but for others it is not.
I have done the following
width of combo box = num characters* size of font;
Please help.
Prithaa
|
|
|
|
|
Do you need to MoveWindow?
|
|
|
|
|
Hello,
Thanks for you reply.
No I don't need a MoveWindow .
I want to decide the width of the combo box before displaying it or creating it.
How should I decide the width of the combo box depending upon the number of characters that are going to be in it?
Prithaa
|
|
|
|
|
prithaa wrote: No I don't need a MoveWindow .
If you are against changing the physical width of the control, then you'll have to provide scrolling capability via CComboBox::SetHorizontalExtent() .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
You have a couple of stages to follow then.
1/ How wide is the longest string. You can use GetTextExtent for that. (and GetDC / ReleaseDC / SelectFont etc).
2/ The use that as the width parameter for CreateWindow.
2a/ If you are making a dialog template in memory, rather than with CreateWindow, then you'll have to translate the width into Dialog Units.
Read http://blogs.msdn.com/oldnewthing/archive/2004/06/17/158175.aspx[^] and later articles for a good lesson in how memory constructed dialogs work, dialog units, etc.
Iain.
|
|
|
|
|
Hello,
Thanks for the replies.
I tried SetHorizontalExtent() but there is no change on the dialog.
Can there be some way where I cn properly decide width of according to fontsize and number of characters ?
Prithaa
|
|
|
|
|
prithaa wrote: I tried SetHorizontalExtent()...
Using what argument? What was the control's horizontal extent before you changed it? Did you ensure that the listbox had the WS_HSCROLL style?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello,
Yes, it worked.I can see the horizontal scroll bar and it can move.
But can I give a width beforehand depending on the number of characters and font size so that I don't have to use SetHorizontalExtent() .
Thanks,
Prithaa
|
|
|
|
|
prithaa wrote: But can I give a width beforehand...
Before what?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Can you give some real font example that is not performing as expected?
I think there is a difference in measuring different types of fonts.
|
|
|
|
|
Hi,
Am getting data from the serialport, when i call MComm->Getinput function to get the data from serial port, the data is stored in Variant type of data(result).I want to store this data in a safearray how to do that.
VARIANT CMSComm::GetInput()
{
VARIANT result;
InvokeHelper(0x1a, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL);
unsigned int i;
HRESULT hresult;
VARIANT var;
SAFEARRAY * psa;
SAFEARRAYBOUND rgsabound[1];
VARIANT *pData;
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = 10;
psa = SafeArrayCreate(VT_BSTR, 1, rgsabound);
var.vt=VT_ARRAY|VT_BSTR;
SafeArrayAccessData(psa, (void HUGEP**)&pData);
pData= result; // error:am not able to assign like this
var.parray=psa;
return var;
}
Thnaks
|
|
|
|
|
I'm no COM expert, but isn't there a way to get the Variant to collapse to a BSTR? Then store that in your array.
Just split the problem in two, and you have solvable bits.
Iain.
|
|
|
|
|
Your immediate problem would seem to be the need to use
<br />
*pData = result;<br />
not that just changing that is going to make your code work.
More generally if you're getting unparsed binary data in a VARIANT from a COM object isn't it already in a SafeArray?
Check the type of the VARIANT and the contents of its array members. I suspect you'll find the VARIANT already is a SafeArray just disguised for COM/OLE Automation correctness.
If not then I would do everything possible to keep the data away from SafeArrays which are code bloaty and awkward unless you're forced to interact with classic VB in which case they're also essential. Good luck.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Hello all's
I am working in VC++ from last some time . I have study it myself also
can any one told me any link for interview question for MFC for 0-2 year exp.
Note : i know its very basic question but i am start from Basic.
Regard's
Kaushik
|
|
|
|
|
Y_Kaushik wrote: : i know its very basic question but i am start from Basic.
Do you want to start to learn?
|
|
|
|
|
If you start to teach i can start
Regard's
Kaushik
|
|
|
|
|
I can help you like a friend or a classmate but for teach you need a teacher.;)
|
|
|
|
|
Hello, I'm a beginner in C++ programming, and I have realized a little app showing the day's appointments, or birthdays; a calendar, shortly.
My app starts minimized in tray (I follow the accurate tutorials on this site), but I noticed that, differently from window minimized, system memory used is the same as the open window, in this case some MBs, while minimized my app uses only 600KBs.
Is there a trick to reduce memory usage in case of application running in tray? Or, the same, minimizing the window but at the same time moving it to tray? Thanks, Simone.
|
|
|
|
|
Hi,
What do u think is faster to compare a secuence of BYTES that can has [192, 4096] positions?
My boss did it with two BYTE BufferX[4096], one to hold the actual project code and the other to hold the PLC saved code in order to compare both of them on the fly. And he has said that he wants it to be done in another way because the performance was very slow.
The secuence of bytes has a logical strructure and I have already the code to write it in a file, I write using tokens of different length according to the meaning and the configuration of the actual project. And the Plc should have the same bytes in the same order.
I thought to make it using the functions I already have (and work) to create an "AktualProject.pc" and get the secuence of the PLC and create an "OnlineProject.pc". Then open both of them and compare byte per byte doing an iteration till the end of the files. When a difference come... error.
But a partner has told me it may be faster with DAO. Writing my the actual code to a row (or a column), the online code to another row (or column, I don't know what will be better) and then compare the contents of both using database requests.
What do you think it is better? My boss priority is quickness of the programm, but I have never used DAO before.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Nelek wrote: What do you think it is better?
It matters not what we think. What matters is the empirical data that you gather to appease them both. You can't use here-say when comparing metrics. Code up both ways so that you can confidently say which way performs better.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
The problem is that I don't know about DAO. Because of that I have asked.
If DAO is faster then I will learn and try it, if more or less are the same, I can use what I already know and don't delay it more than strictly needed.
Anyways thanks for answering.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Nelek wrote: If DAO is faster...
Whether it is or isn't, you won't actually know until you code something up to test with. DAO may be faster in scenario A, but slower in scenario B.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hey guys,
Can anybody tell me how to create a dll that ca be successfully fully loaded in some other language like vb and can be used there.
Regards,
Pankaj Sachdeva
"There is no future lies in any job"
"but"
"future lies in the person who holds the job"
|
|
|
|
|
I have no idea (yet), I need to learn about DLLs too, So I was looking in the DLL section here in codeproject.
I think This link[^] and the other 3 articles of the same group can help you.
Is about writing a C++ from VC++ and VB. It has information about compatibilities and so on. Maybe is not what you exactly look for, but it has lot of comments/points tht will help you.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|