|
Hmmm food for thought. Thanks so much for taking the time to help Luc I'll respond back here with whatever I come up with.
|
|
|
|
|
|
Hi all,
I just want to know how to put a value in a string pointer for example
std::string *text;
How do I put a wstring value in there because everytime I try even with the use of USES_CONVERSION and WideCharToMultiByte I get a
bad ptr
Thanks,
Jayjay
modified on Monday, July 28, 2008 9:30 PM
|
|
|
|
|
First, since text is a pointer, it needs to be assigned the
address of a string object to point to. You could use the
new operator to allocate a string.
Two ways to assign a value to the string are using a constructor
and using the string class' assignment operator overload:
std::string *text;
text = new std::string("Assigned Text");
std::string *text;
text = new std::string();
*text = "Assigned Text";
Or automatic variable (stack based)/class member semantics:
std::string text("Assigned Text");
std::string text;
text = "Assigned Text";
This is fundamental C++ stuff...you may want to study
basic_string Class[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I think still you're in trouble with wstring to string conversion. http://www.codeproject.com/script/Forums/View.aspx?fid=1647&msg=2653980[^]
Well, the capsule answer for your query is this -
#include "atlconv.h"
string* WstringToString( wstring& WideString )
{
string* pString = new string;
{
USES_CONVERSION;
*pString = W2A( WideString.c_str());
}
return pString;
}
void ConversionFunction()
{
wstring WideString = L"Hello";
string* pString = WstringToString( WideString );
delete pString;
}
Hope its clear now!
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Hi all, I'm using VC++ with Windows API, no MFC. I want to create a dialog that is entirely owner-drawn, but I can't find a style to use with it (buttons being BS_OWNERDRAW, etc). Is there a style for owner-drawing entire dialogs or do I have to do this in some other way?
Thanks!
KR
|
|
|
|
|
Just register your own window class and run a message pump.
Steve
|
|
|
|
|
The dialog is created as a popup for my application which is already registered. I'm not sure how registering the dialog would help as it already has a message pump? Or maybe I don't understand what you mean? How can I use the dialog's message pump to custom draw the dialog? If I use WM_PAINT I can only draw in the client area of the dialog, right? If I set the dialog's border to "None" then I can basically draw the entire thing as long as I use a square bitmap... but I don't want it to be square, and if I draw the bitmap transparently I see the gray crap beneath it... isn't there a way I can just override the default drawing behavior of the dialog in the same way that I catch the WM_DRAWITEM message for my other custom controls? Thanks!
KR
|
|
|
|
|
What I'm saying is that if you want a dialog-like window that's totally user drawn then just make one: don't use the CreateDialog function and friends. If the dialog is to be modal all you have to do is disable it's parent and you may want to run a your own message pump.
Steve
|
|
|
|
|
Oh ok, I get it. Thanks!
KR
|
|
|
|
|
I need an Efficient Object Management Class to add, remove, get and set (Manage Actually) objects of my own class.
I read somewhere that std::list will do this job but i did not find the function for removing objects or get or set properties of existing objects.
Any suggestions?
|
|
|
|
|
Your question is not really clear but it sesems that you simply need some kind of container (std::list is a container class). Why do you call the an "Object Management Class" ?
Anyway, the way to access elements in a std::list is by using an iterator. The iterator overload * and -> operators that give you access to the object pointed by the iterator. To remove objects, simply erase the iterator (it has an erase member function).
But I suggest that you first read some tutorial about how to use those classes from the STL because it could be quite difficult to start with that without a good tutorial. Just google for it and I am sure you'll find plenty.
|
|
|
|
|
thanks for your help
|
|
|
|
|
Hi all in my application i have to do serial communication via port.
I want to populate my comboboxes of "databits' "parity" "stopbits' "bits per second" values as how the values are populated in the hyper termainal
can anybody please suggest me the possible values for those comboboxes population.
Thanks in advance...
|
|
|
|
|
|
Aren't the HyperTerminal comboboxes telling you?
modified on Monday, July 28, 2008 4:46 PM
|
|
|
|
|
In my applicationi would like to give the comboboxes and its values as how they will be available for the hyperterminal.
more or less like a hypertermianl values for baudrate,parity,databits,stopbits etc
|
|
|
|
|
So what is your exact question ? Because ass far as I read you only wanted to know which options you can provide to the user, and for that Luc's answer was correct. But apparently it wasn't because you (I guess) voted him down. So what are you looking for exactly ? What is your problem ?
|
|
|
|
|
Is there a way to get/enumerate the available sizes for a particular font ? heck, I don't even know if it does make
sense.
I only found example where the sizes are added manually (6, 8, 10, ...), but not automatically.
Not urgent.
Thanks.
Max.
This signature was proudly tested on animals.
|
|
|
|
|
MSDN:The EnumFontFamiliesEx function enumerates all fonts in the system that match the font characteristics specified by the LOGFONT structure. EnumFontFamiliesEx enumerates fonts based on typeface name, character set, or both.
Maximilien wrote: Not urgent.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Thanks.
according to this[^] it can work for NON true type fonts.
For true-type fonts, it does not matter.
|
|
|
|
|
Hi i want to use the shortcuts for handling the menu operations in my application.
can anybody suggest me how to do that??????
For ex:if i click "ctrl+ space" window shud exit etc...
Thnaks in advance
|
|
|
|
|
Hi all i am new to vc++.
i want to have tooltips for the controls in my application but i am not able to generate the tool tips for the controls inside the group box using
ON_NOTIFY_EX(TTN_NEEDTEXT,0,OnToolTipNotify)
Can anybody suggest me the apt way for doing it..
Thanks in advance
|
|
|
|
|
I'm a newbie to MFC or even WIN32 GDI programming too.
I've tried your test.(Eg, deal with TTN_NEEDTEXT notification)
Yes, in the group box it doesn't work at all.
But indeed, we can figure out this problem by using ::CreateWindowEx, passing the TOOLTIPS_CLASS as the window class name,
This link would help you.http://www.codeproject.com/KB/cpp/Tool_Tip.aspx[^]
If you're using VC6.0, you'll encounter this compile error:
<br />
error C2065: 'TTS_BALLOON' : undeclared identifier
I haven't found an excellent resolution. And I googled, someone fixed this by adding this line(in the stdafx.h or somewhere):
<br />
#define TTS_BALLOON 0x40
If you found why 'TTS_BALLOON' showed undeclared, please reply my thread, I'd like to know too.
|
|
|
|
|
Excute me, I wanna to show multi-lines in the tooltips. I add '\n' in the text, it doesn't work.
Can somebody help me?
DWORD dwToolStyle = WS_EX_TOOLWINDOW | WS_EX_TOPMOST |WS_EX_WINDOWEDGE;
m_hwndTooltip = ::CreateWindowEx(dwToolStyle, TOOLTIPS_CLASS, NULL,
WS_POPUP | TTS_ALWAYSTIP | TTS_NOPREFIX | TTS_BALLOON,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
this->GetSafeHwnd(), NULL, ::AfxGetResourceHandle(), NULL);
ASSERT(m_hwndTooltip);
::SendMessage(m_hwndTooltip, TTM_ACTIVATE, (WPARAM)TRUE, NULL);
::SendMessage(m_hwndTooltip, TTM_SETDELAYTIME, TTDT_INITIAL, MAKELONG(1000, 0));
::SendMessage(m_hwndTooltip, TTM_SETDELAYTIME, TTDT_AUTOPOP, MAKELONG(1000, 0));
::SendMessage(m_hwndTooltip, TTM_SETDELAYTIME, TTDT_RESHOW, MAKELONG(1000, 0));
TOOLINFO info = {0};
info.cbSize = sizeof(TOOLINFO);
info.uFlags = TTF_CENTERTIP | TTF_IDISHWND | TTF_SUBCLASS;
info.hwnd = this->GetSafeHwnd();
info.uId = (UINT)::GetDlgItem(this->GetSafeHwnd(), IDC_APPLE);
info.rect = CRect(0, 0, 0, 0);
info.hinst = ::AfxGetResourceHandle();
info.lpszText = _T("You can check this to see\n\n\nwhat is this");
if ( !::SendMessage(m_hwndTooltip, TTM_ADDTOOL, NULL, (LPARAM)&info) )
{
::AfxMessageBox("Add tool fail");
}
|
|
|
|