|
how can i display an integer using MessageBox command?how can i convert an integer value to string?
|
|
|
|
|
char buf[81];
int i = 2;
sprintf(buf, "%d", i);
AfxMessageBox(buf);
|
|
|
|
|
CString buf;
buf.Format ("%i", iMyInt);
MessageBox (buf);
Tada!
Now, if you mean converting 1234 to one thousand, two hundred and thirty four,
as I *think* you asked earlier, I still don't know of a nice neat function.
It would be language dependent too...
Iain.
|
|
|
|
|
Iain Clarke wrote:
Now, if you mean converting 1234 to one thousand, two hundred and thirty four,
as I *think* you asked earlier, I still don't know of a nice neat function.
|
|
|
|
|
itoa(iValue,caBuffer,10);
onwards and upwards...
|
|
|
|
|
Can anyone tell me the url of websites where the efficieny of vc++ developer is tested? ie Online free exam for mfc programming or c++ programming.
Using the tests, the efficiency of the developer is tested.
I have also another question , the question is
What is the importance of ATL in vc++ programming ?
Can any one please help me in this matter.
PHILIP
|
|
|
|
|
phijophlip wrote:
Can anyone tell me the url of websites where the efficieny of vc++ developer is tested?
Efficiency is a very subjective metric. You could ask ten people what makes an efficient programmer and get ten different answers.
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 Walliams (Little Britain)
|
|
|
|
|
phijophlip wrote:
Can anyone tell me the url of websites where the efficieny of vc++ developer is tested? ie Online free exam for mfc programming or c++ programming.
Remember that you get what you pay for. While they are not free, you might try brainbench.com[^] and transcender.com[^].
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi
Could anyone of you please tell me the best way to do reporting in vc++.
I have seen people using msdbrpt.dll in vb. Is there something similar for vc++ that can be used for reporting.
Can I use crystal reports, shipped with vs, in comercial application.(any License Issues ??).
Regards
Shiraz
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|
|
zainu wrote:
Can I use crystal reports, shipped with vs, in comercial application.(any License Issues ??).
As long as you own at least one fully licensed copy VS then you can ship the crystal reports with commercial software.
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 Walliams (Little Britain)
|
|
|
|
|
Hello,
I need to create a form with multiple buttons instances. In C#, this
would look like this
static string[] strCaption={"Button A","Button B","Button C"};
Button[] btnShow=new Button[strCaption.Length];
for(int i=0 ; i < strCaption.Length ; i++)
{
btnShow[i]=new Button();
btnShow[i].Text=strCaption[i];
btnShow[i].Size=new Size(200,20);
btnShow[i].Location=new Point(10,35*i+20);
btnShow[i].Click+=new EventHandler(Button_Click);
btnShow[i].Tag=i.ToString();
this.Controls.Add(btnShow[i]);
}
I try to code this in C++, but I have a lot troubles setting the
identifiers.
This:
Button* btnShow[]
...
btnShow[i]=new Button();
...
Does not work. Any suggestions/code samples?
Thanks in advance,
Picander
|
|
|
|
|
you should allocate first the size of your button array, either statically (Button *btnShow[10]; ) or dynamically ( Button **ppBtnShow; ppBtnShow = (Button **)calloc(10, sizeof(Button *)); [...] ppBtnShow[i] = new Button; ). In the last case don't forget to free your data to avoid memory leaks!
Fold With Us!
Sie wollen mein Herz am rechten Fleck
Doch seh ich dann nach unten weg
Da schlägt es links
|
|
|
|
|
I think it is better to have an array that contains directly the buttons and not the pointers to the buttons (otherwise you will need to destroy your buttons after use, ...).
So it looks like:
CButton* m_pButtonArray;
And to create for example 10 buttons:
m_pButtonArray = new CButton[10];
Then you will need to 'initialize' them using the Create method and then call ShowWindow(SW_SHOW) for all of them.
Hope this helps
|
|
|
|
|
Hi Picander,
You forgot to attatch your code, and you didn't mention which compiler your are using VC6.0 or DOT net. Well I gave a try to do the same stuff you have tried, with MCF in VC6.0. You might take a look to it.
//---------------------------------------------------
char *strCaption[3]= {"Button A","Button B","Button C"};
char buffer[20];
int butt_width = 90,
butt_height = 30,
butt_pad = 10;
CButton *myButton = new CButton[3];
// Create a push button.
for(int i=1 ; i <= 3 ; i++)
{
myButton[i-1].Create(strCaption[i-1], WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, CRect(10, 10 + butt_height * (i-1), 100, butt_height*i), this, 1);
//add code to populate variables
}
//--------------------------------------------------------
Good Day
Sohail
|
|
|
|
|
Thanks for the reply Sohail!
I forgot to mention that I am developing a .NET windows forms application.
Button *myButton = new Button[3];
does not work...
gui\myForm.cpp(87) : error C2691: 'System::Windows::Forms::Button' : invalid type for __gc array element
gui\myForm.cpp(87) : error C3149: 'System::Windows::Forms::Button' : illegal use of managed type 'System::Windows::Forms::Button'; did you forget a '*'?
gui\myForm.cpp(87) : error C2691: 'System::Windows::Forms::Button __gc *' : invalid type for __gc array element
i have tried many other options, as other posted suggested and i still cannot get it working.
I cannot find on the net any similar code sample for c++.
|
|
|
|
|
you need to reserve a range of continuous resource ID for your array of buttons; and manually create a ON_CONTROL_RANGE entry in the message map.
The problem with MFC is that you need to have a predefined ID range; you can't create the buttons with no defined ID and have it registered in the message map ( or I think so ).
ON_CONTROL_RANGEBN_CLICKED, id1, id2, OnButtonsClicked)
void YourMethod::OnButtonsClicked(UINT nCmdID)
{
switch ( nCmdID )
{
case id1:
...
case id2:
break;
default:
break;
}
}
One other way would be to create your own class of button that have callbacks that can be sent to the parent window.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Thanks for all the replies! You are great folks!
Here is the combination of your suggestions:
Button* myButtons[];
myButtons= new Button *[20];
for (int i = 0; i < 20; i++)
myButtons[i] = new Button();
|
|
|
|
|
Thanks for all the replies! You are great folks!
For a .net managed c++ windows form application, here is the combination of your suggestions:
Button* myButtons[];
myButtons= new Button *[20];
for (int i = 0; i < 20; i++)
myButtons[i] = new Button();
|
|
|
|
|
hi all there, i want a code that help me to insert any file type in a rtf file, i need to insert by code not drag drop by mouse so plzzzzzzzzzzzzz help me .......
Thanks alot
Metal Man
|
|
|
|
|
Hi. Can anyone help me on this: I need to read data from sound card on line in. All I want is to get the digitized data that represents the signal I apply to line in. If anyone could suggest me some docs, or anything related to this I would be thankful.
PLEASE HELP !!! Thank you.;)
|
|
|
|
|
|
hello,
I have a problem. the call SETWINDOWTEXT truncates the length of the displayed text to 259 characters (dialog based, ansi mode) (somebody else reported 159), i don't see any dots, also a lot of space is left on the bar. A getwindowtext will return the full original string.
I try to set a titlebar of my dialog with 3 strings which are left, center and right justified. I do this by inserting a lot of spaces between the strings
Things i can do, but don't wan't to:
- Change the active title bar font.
- Draw my own titlebar.
The following code will work on a 800x600 mode maximized dialog, but not on a 1600x1200.
<code>
void SetWindowText3(CWnd* TargetWnd, CString LeftText, CString MidText, CString RightText)
{
CRect Rect;
int CaptionWidth;
CFont font;
CDC dc;
NONCLIENTMETRICS ncm;
int LeftWidth;
int MidWidth;
int RightWidth;
int SpaceWidth;
int FillWidth;
int FillLeftWidth;
int FillRightWidth;
int PosCenter;
CString CaptionText;
/****************************************************************************
Figure out the maximum width of the caption text
****************************************************************************/
TargetWnd->GetWindowRect(Rect);
CaptionWidth = Rect.Width(); // get width of whole window
CaptionWidth -= 2*GetSystemMetrics(SM_CXBORDER); // Remove left and right the border width
CaptionWidth -= 2*GetSystemMetrics(SM_CXFRAME); // Remove left and right the frame width
if (TargetWnd->GetStyle() & WS_SYSMENU)
CaptionWidth -= 2*GetSystemMetrics(SM_CXSIZE); // Remove the icon and close button
else
CaptionWidth -= 5; // Remove extra edge if no close button
PosCenter = CaptionWidth/2;
if ( (TargetWnd->GetStyle() & WS_MAXIMIZEBOX)
|| (TargetWnd->GetStyle() & WS_MINIMIZEBOX) )
CaptionWidth -= (2*GetSystemMetrics(SM_CXSIZE)) - 1; // Remove the width of the minimizebutton
/****************************************************************************
Prepare the GetTextExtent function.
****************************************************************************/
ncm.cbSize = sizeof(NONCLIENTMETRICS); // i don't why this is used.
SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
sizeof(NONCLIENTMETRICS), &ncm, 0); // get the pointer to the nonclientmetrics struct
font.CreateFontIndirect(&ncm.lfCaptionFont); // Create a copy of the font used title bar
dc.CreateCompatibleDC(NULL); // Create an DC
CFont* pOldFont = (CFont*)dc.SelectObject(&font); // Make sure that gettextextent uses the correct font.
dc.SetMapMode(MM_TEXT); // Make sure that gettextextent returns PIXELS.
/****************************************************************************
Get various width in pixels of the thext
****************************************************************************/
LeftWidth = dc.GetTextExtent(LeftText).cx; // Get the text width of the left text.
MidWidth = dc.GetTextExtent(MidText).cx; // Get the text width of the mid text.
RightWidth = dc.GetTextExtent(RightText).cx; // Get the text width of the right text.
SpaceWidth = dc.GetTextExtent(_T(" ")).cx; // How many pixels does a space take
FillWidth = (CaptionWidth - LeftWidth -
MidWidth - RightWidth)/SpaceWidth; // How much space is left on the title bar?
/****************************************************************************
Bug Work around. Make sure text is never longer as 259 characters
****************************************************************************/
// if ((LeftText.GetLength()+MidText.GetLength()+RightText.GetLength()+FillWidth)>259)
// FillWidth = 259 - (LeftText.GetLength()+MidText.GetLength()+RightText.GetLength());
/****************************************************************************
Fill in the spaces between the text and write the text to the title bar
****************************************************************************/
FillLeftWidth = (PosCenter-LeftWidth-(MidWidth/2))/SpaceWidth; // Space (in characters) between left and middle
//FillLeftWidth = FillWidth/2; // Same as above, but midtext in middle of empty area
FillRightWidth = FillWidth - FillLeftWidth; // space (in characters) between middle and right
CaptionText = LeftText;
for (int loopy=0;loopy<FillLeftWidth;loopy++) // How many space are needed between left and middle?
CaptionText += _T(" "); // Add a space to the caption text
CaptionText += MidText; // Add the middle text to the caption text
for (int loopy=0;loopy<FillRightWidth;loopy++) // How many space are needed between middle and right?
CaptionText += _T(" "); // Add a space to the caption text
CaptionText += RightText; // Add the right text tot the caption text
TargetWnd->SetWindowText(CaptionText); // now actually set the windows text
/****************************************************************************
Delete temperary objects
****************************************************************************/
dc.SelectObject(pOldFont);
font.DeleteObject(); // Delete the font.
dc.DeleteDC(); // Delete the DC
}
</code>
|
|
|
|
|
|
Hello! I've seen some sample programs on how to use CRectTracker properly, but i only have seen it on ordinary CViews...
I noticed the problem when i used CScrollViews and when I'm scrolling..
When I scroll the view, the CRectTracker also scrolls, thats fine.. But when I scroll all the way to the right, the CRectTracker is supposed to disappear, since its coordinates is out of the view already, and thats fine... But When I scroll back to its position, i expected to see it back, but i didn't.... I want the CRectTracker to be appearing again..
How do i solve this?
|
|
|
|
|
Hello,
i'm programming a multithreaded communication application. Some of the communication operations are being hold in a a shared (for all threads) synchronized queue. the synchronized queue is using c++ 'CRITICAL_SECTION' handle (using the 'EnterCriticalSection' and 'LeaveCriticalSection' functions).
have three questions (actually it's two):
1) Is 'CRITICAL_SECTION' ensure FIFO threads access into the critial sections of code?
2) If not, what can i use to ensure FIFO access?
3) If yes, is there a better (less CPU time, less resources) way to ensure FIFO access to critical sections of code?
thanks
|
|
|
|