|
you could just do this:
cout << s << a << endl;
------- signature starts
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
Please review the Legal Disclaimer in my bio.
------- signature ends
|
|
|
|
|
I forgot to mention:
The new string has to be stored (as a string) in a vector of strings. So printing it immediately was not my original pupose, just an example.
-----------------------
But what did I do?
|
|
|
|
|
Use a stringstream, then extract the string out of it.
Also, look at boost::lexical_cast
HTH
--
Ian Darling
|
|
|
|
|
int i = 98;
char* c;
itoa(i, c, 10);
c now has "98"
|
|
|
|
|
Actually, c now contains nothing because your program just went BOOM.
int i = 98;
char s [64];
itoa (i, s, 10);
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Yes it helps. Thank You.
Another Q:
When I create an object, string for example, with the syntax:
string s ;
s now is on the heap or on the stack? is s a pointer or is it a synonym of the address of the first block of memory where the object string is defined (kind of a reference)? do I have to delete s after usage? I'm confused
Thank you for all your previous answers
-----------------------
But what did I do?
|
|
|
|
|
If the definition is inside a function, the varible is on the stack. This is called an "automatic" variable which means it's destroyed when the function exits. You delete only variables you have allocated with new
|
|
|
|
|
stringstream was made for just this job:
ostringstream strm;
string s;
strm << "Yes" << 98 << ends;
s = strm.str();
--Mike--
THERE IS NO THERE IS NO BUT THERE IS
MAGIC PIXIE DUST BUSINESS GENIE CODE PROJECT
Homepage | RightClick-Encrypt | 1ClickPicGrabber
"Which comes first, the bug or the stress?" -- Chris Maunder
|
|
|
|
|
I create a SDI project.At Step6 I change CView to CFormView.After then I add a CTreeCtrl in my frame for display some data ,and I add some dialog .Now I have a question: when I click menu create the dialog and then click OK return to the Frame,I want to refresh the data in CTreeCtrl,but I don't know how ?
Help me !
|
|
|
|
|
One solution is Invalidate().
Kuphryn
|
|
|
|
|
Hello,
a have a big problem ... I tried to paint a dc with BitBlt (win32 api NOT MFC) and it did not work, my code is :
HDC a,b;
a = GetDC(GetDesktopWindow());
b = CreateCompatibleDC(NULL);
BOOL ahr;
ahr = BitBlt(b,0,0,100,100,a,0,0,SRCCOPY);
ahr = BitBlt(hdc,0,0,400,400,b,0,0,SRCCOPY);
the problem is that all functions return OK values and the screen is empty
if I change :
HDC a,b;
a = GetDC(GetDesktopWindow());
b = CreateCompatibleDC(NULL);
BOOL ahr;
ahr = BitBlt(hdc,0,0,100,100,a,0,0,SRCCOPY);
ahr = BitBlt(hdc,0,0,400,400,hdc,0,0,SRCCOPY);
is OK, so I jump to one conclusion that only "hdc" can be painted ....
all is done in the WM_PAINT message
So my question is how can I create a buffer in memory and paint there and in the end paint my app with it !
thank you !
|
|
|
|
|
u need to find a sample in MSDN (many there) and test it to get right idea.
includeh10
|
|
|
|
|
remember, a dc is not a surface, but the means of accessing one.
If you create a memory dc, it is created with a default 1x1
monochrome surface. (If I recall) What you need to do is create
a bitmap (the surface) and select it into the memory dc. Then
you can paint on that surface using the memory dc and finally
blit from the bitmap (using the memory dc) to the display surface
(using the window dc)
|
|
|
|
|
thanks, you were right, it worked !!!
|
|
|
|
|
First of all, it's best to use BeginPaint and EndPaint when painting from the WM_PAINT message:
PAINTSTRUCT ps;
BeginPaint(hwnd,&ps);
//you can use ps.hdc now for drawing
EndPaint(hwnd,&ps);
Otherwise use GetDC() when painting.
The HDC object you have using the above methods can be used for drawing. A HDC object is 'connected' to a certain surface like a bitmap. The 'b' HDC object you use in your code points to nothing so to say, so you need to create a HBITMAP object if you want the code to work:
HBITMAP bmp=CreateCompatibleBitmap(hdc,width,height);
Then use SelectObject(b,bmp); to let 'b' point to the new bitmap. After that you can draw to it/copy to it etc.
Also, I advice you use b=CreateCompatibleDC(hdc); instead of NULL as argument.
|
|
|
|
|
in my PC, when i visit a web site (i.e. google), normally the site is english version.
but, after i run a small laguage support program (which supports other languages), the web site becomes other language version also.
my Q is:
1. what is stroy inside the process, i think my PC knows what language is in use and tells the site about that.
is this guess correct?
2. and how does my PC know and how does the site know?
thanks
includeh10
|
|
|
|
|
includeh10 wrote:
1. what is stroy inside the process
::GetThreadLocale
includeh10 wrote:
2.
to understand it examine
Control Panel->Keyboard
+ regional setting
+ system locale
etc
|
|
|
|
|
u misunderstand the post
1. "the process" is about transaction and encode, not a thread.
2. things are in VC as the name of the site, not from control-panel
includeh10
|
|
|
|
|
I do not think I did. Sorry for using simple terms like "Control panel". The real question how much you have to know (read) to ask the question.
If you asking about HTML encoding it is usually imbedded in meta header of the page. If IE support for the language is installed (lets say Chinese) then page is displayed properly.
If you asking how someone can find out the language settings on the PC, read my previous post and MSDN articles on locale and internationalization.
P.S. What transaction has to do with encode?
|
|
|
|
|
I have the folowing and none of the HWNDs match the CWnd* pCtrl!!! Yet I only have these 4 items on the
dialog:
cmbSel, cmbFile, edit ctrl, list ctrl......WHose pointer is being returned from GetFocus()?
BOOL CAddRecord::OnCommand(WPARAM wParam, LPARAM lParam)
{
if (LOWORD(wParam) == IDOK && lParam == 0)
{
CWnd* pCtrl = GetFocus();
HWND a = pCtrl->GetSafeHwnd();
HWND b = m_cmbSel.GetSafeHwnd();
HWND c = m_editKeyword.GetSafeHwnd();
HWND d = m_listAddRecord.GetSafeHwnd();
HWND e = m_cmbFile.GetSafeHwnd();
if (pCtrl->GetSafeHwnd() == m_cmbSel.GetSafeHwnd())
{
int fileIndex = m_cmbFile.GetCurSel();
FileKVMap & fileKVMap = *m_pFileKVMap;
KeyValueMap& keyValueMap = fileKVMap[fileIndex];
CString value ;
m_cmbSel.GetWindowText(value);
keyValueMap[m_activeKey] = value;
}
}
return CDialog::OnCommand(wParam, lParam);
}
Appreciate your help,
ns
|
|
|
|
|
Can you add some detail re: what you're trying to achieve? I recall it had to do with automatically setting focus to a specific control.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Want to trap the "enter" key when the combobox on the CDialog is pressed. SO was looking for LOWORD(wPARAM) == IDOK....
Right now I'm just checking to see if theres anything in the combobox editpart. If so then do blah blah (in the OnComand). But my intent was to see if the GetFocus() was identifying who the enter issued from.....
Is this clearer?
Appreciate your help,
ns
|
|
|
|
|
ns wrote:
Want to trap the "enter" key when the combobox on the CDialog is pressed.
Not sure what you mean by "trapping the Enter key when the combobox is pressed". Do you mean you want to do something special when the user clicks Enter if they've activated the combobox?
If so, just set a flag bComboBoxActivated in the combobox's CBN_CLOSEUP handler. Then, check the state of the flag in your dialog's OnOK() .
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
What I want to do:
The user enters something manually in the edit part of the combo. When he hits enter I want to add it to the combobox strings. Its not a selection from the preexisting list, but a new entry. SO theres no close-up action happening - right?
So basically all I want to do is add the users input to the list of strings...
Appreciate your help,
ns
|
|
|
|
|
ns wrote:
all I want to do is add the users input to the list of strings...
Ah.
Try using a CComboBoxEx instead of a regular CComboBox . Then, handle the CBEN_ENDEDIT message. If the iWhy member of the NMCBEENDEDIT struct is CBENF_RETURN , the user pressed Enter in the combobox's edit control. Get the text from the szText member and add it to the combobox.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|