|
CString str;
str.Format("%i", int_nr);
//str will now be equal to int_nr even if str had another value
good luck.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
If I understand your question correctly, I can only offer this:
struct
{
int m_var1;
int m_var2;
int m_var3;
int m_var4;
int m_var5;
int m_var6;
int m_var7;
int m_var8;
int m_var9;
int m_var10;
} m_vars;
int *pVar = &m_vars.m_var1;
for (int x = 0; x < sizeof(m_vars) / sizeof(int); x++)
{
*pVar = 1;
pVar++;
}
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
|
I'd like to customize the CFileDialog to add some extra controls to the bottom of it. When the dialog first opens, I'd only like one of the extra controls to be displayed. When the user selects this control (a check box), then I'd like the dialog to expand to show the rest of the controls.
I am using the explorer style CFileDialog with a custom template. If I place all of the extra controls on the custom template, the size of the CFileDialog is extended to include all of these controls (even if they are not visible). So I get the CFileDialog w/ a bunch of extra gray space at the bottom of it.
I thought that I could make the invisible controls very small in the custom template to minimize this extra gray space. Then when they need to be seen, I'd resize the CFileDialog and the controls and set the controls visible. The problem is that whenever I change the size of the CFileDialog by calling SetWindowPos(), the original CFileDialog controls resize to fill up the extra space, leaving no extra room for my new controls.
Does anyone know how to customize the CFileDialog to allow for collapse/expand at the bottom of the dialog? If so, I could really use some suggestions. Thanks!
|
|
|
|
|
Hi,
I needed help with resizing a CStatic box to fit exactly the size of the text inside. The thing is once I increase the font size, I cant get the exact dimensions from GetTextExtent(). I've tried to multiply it with a ration, but no luck. It doesnt fit on it. Is there any function out there that can do this for me or any help on what would be a good way to do it. Help Needed ASAP.
A
|
|
|
|
|
GetTextExtent has always worked for me. Show your code and maybe we can help.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
I was just testing to see what font is currently stored in CDC object and it turns out that it is totally different from the font of the window. Why is that? and how do I change the font of CDC object as there is no setFont function there.
the code is below:
//set the font of the window text
CWnd* pCtrlWnd = GetDlgItem(id);
CFont * oldFont = pCtrlWnd->GetFont();
LOGFONT* pLogFont = new LOGFONT;
oldFont->GetLogFont(pLogFont);
CString fontName = pLogFont->lfFaceName;
CFont * font = new CFont;
font->CreateFont(newFontSize,0,0,0,700,0,0,0,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, fontName);
//get the draw context of window
pCtrlWnd->SetFont(font);
//resize the window
CDC* pDC = pCtrlWnd->GetDC();
CString text;
pCtrlWnd->GetWindowText(text);
//get the textExtent
CSize stringSize = pDC->GetTextExtent(text);
pCtrlWnd->SetWindowPos(NULL, 0, 0, stringSize.cx * 1.4 , stringSize.cy * 1.45, SWP_NOMOVE|SWP_NOZORDER|SWP_NOREPOSITION);
}
A
|
|
|
|
|
Ali Niaz wrote:
how do I change the font of CDC object
SelectObject() will do that for you.
I see several problems with the code you supplied. The most obvious being the severe potential for memory leaks. See http://www.codeproject.com/gdi/drawtechniques.asp[^]. You might also want to make your font a member variable of your static control's parent window.
CDC* pDC = pCtrlWnd->GetDC();
CString text;
pCtrlWnd->GetWindowText(text);
CFont *pOld = pDC->SelectObject(font);
CSize stringsize = pDC->GetTextExtent(text);
pDC->SelectObject(pOld);
...
See also:
http://www.codeproject.com/cpp/nogetdlgitem.asp[^]
http://www.codeproject.com/gdi/csavedc.asp[^]
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
sorry its ERROR_ACCESS_DENIED
|
|
|
|
|
Hai,
I'm opening a serial port COM1 as follows..
static LPTSTR portname = "\\\\.\\COM1\0";
HANDLE hComPort = CreateFile( portname, GENERIC_READ |GENERIC_WRITE, //bidirectional
0, NULL, //no security OPEN_EXISTING, 0, NULL );
if (hComPort == INVALID_HANDLE_VALUE)
{
sprintf(errstr,"Could not open file (error %d)\n", GetLastError());
MsgBox(errstr);
}
But it is giving me ERROR_INVALID_HANDLE..
What did I miss...pls help..
thanks a lot.
|
|
|
|
|
Is COM1 in use by any other processes?
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I don't think so...I have a controller connected to the com1..i'm trying to send data to the controller..
but how can i find whether any other process is using com1??
thanks a lot.
|
|
|
|
|
Try Portmon from sysinternals, freeware
"An expert is a person who has made all the mistakes that can be made in a very narrow field." - Neils Bohr
|
|
|
|
|
changing icon of an exe file by peplacing icon resource inside the exe file.
It is easy if using UpdateResource().
but my users use all OS including win95 and win98.
the program using UpdateResource() will not work on win95/98 because the function is not supportted on 95/98.
do you have idea to implement the task?
thx
includeh10
|
|
|
|
|
Check Erik Kallen's article Updating Resources on Win9x[^], which provides a replacement for UpdateResource and familiy in Win9x systems. I've used this library in the past and it works like a charm.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
thx
I will try it.
includeh10
|
|
|
|
|
I have a database program that I am working on that uses CString for a description of a product, is there anyway to get more than the 256 charecters or do I have to use a diffrent type of string?
|
|
|
|
|
CString has no size limit, other than available memory. Something else is creating the 256-char limit.
--
I'm Michael Dunn and I approve this post.
Vote Trogdor in oh-four!
|
|
|
|
|
Many Databases limit String fields to 256 characters.
They do offer "MEMO" fields with 64K/unlimited length, but typically they cannot be searched, or indexed.
we are here to help each other get through this thing, whatever it is Vonnegut jr.
sighist Fold With Us! || Agile Programming | doxygen
|
|
|
|
|
I've just started to program Windows Forms apps in VC++ .NET.
I have prior experience in developing WinForms apps in C# .NET, and the confusion that leads to my question is rooted in the jump from C# to C++.
In C#, when I add a button to the form and create an event handler function this function is visible in my code file.
However, in VC++, the designer is the ".h" file and the InitializeComponent function is also in the ".h" file.
The event handler function is also added in the ".h" file.
My question is this:
What code is added in the project's ".cpp" file? By that, I mean to ask, what part of my program should be coded in the .cpp file?
How do I access the components, say btn1 , btn2 etc from the .cpp file.
|
|
|
|
|
Hi Friends,
How to get the items from the listcontrol on scrolling vertically.
I have dialog with listcontrol. I have created seperate class for listcontrol to catch veticall scrollbar. Once uset start scrolling vertically i have to fetch the row from the Listcontrol.
Please suggest me how to do this.
Your help is appreciated.
Please response to purushotham.chandrashekar@orange.co.uk.
Thanks in advance
|
|
|
|
|
I got problem,i have a programm that stops and sends error!!! But when i try to debug my programm it can't show me the place where the mistake must be. In other words i run my programm, and it shows me the message :"Unhandled exception at 0x77f759e4 in NeuralGas.exe: User breakpoint." and jumps on dbgheap.c on 1807 string. I don't know where the problem, but when i push the continue button it shows next:" Debug Assertation Failed!... _CrtIsValidHeapPointer(pUserData)...
And i noticed one thing - i use the recursive function (quick sort algorithm), when i avoid this function my programm works, may be problem in initial stack??? Where can i make it larger?
I can share my project with everyone who can help - just give me your e-mail.
Please help.............
|
|
|
|
|
Maybe you could provide some more info on how you are catching this error? What version of VC are you using? Are you catching this in the debugger? Is this a release or debug build (I am presuming a debug build from your comment about the assert)? _CrtIsValidHeapPointer probably indicates you have overwritten some memory somewhere or are trying to free memory that's already been freed, or perhaps access memory that's already been freed.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|
|
|
Uhhh, is that a "Thank you - it helped" or a "Thank you, and drop dead" ?
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|