|
You cannot sprintf a null character using %s, because "\0" looks the same as "", which is no characters at all. You'll need to put the extra null char there yourself - I usually zero out the entire buffer beforehand so I don't have to worry about finding the exact end of the string and tacking on an extra 0.
--Mike--
Buy me stuff!
Like the Google toolbar? Then check out UltraBar, with more features & customizable search engines!
My really out-of-date homepage
Big fan of Alyson Hannigan and Jamie Salé.
|
|
|
|
|
|
Hi
I am using IActiveDesktop::SetWallpaper to change ative desktop wallpaper.
//--------------------------------------------------------------------------
HRESULT hr;
WCHAR wszWallpaper [MAX_PATH];
IActiveDesktop* pDesktop;
CoInitialize(NULL);
hr = CoCreateInstance (CLSID_ActiveDesktop, NULL, CLSCTX_INPROC_SERVER,
IID_IActiveDesktop, (void**) &pDesktop);
if (SUCCEEDED(hr))
{
mbstowcs(wszWallpaper, strFileName, sizeof wszWallpaper);
hr = pDesktop->SetWallpaper(wszWallpaper, 0);
pDesktop->Release();
}
CoUninitialize();
//---------------------------------------------------------------------------
But it does not work. No error, the old wallpaper simply stays. Does somebody has any idea?
thx
|
|
|
|
|
I think ActiveDesktop works only if it is enabled. Try to set manually a JPEG (not BMP) file as a wallpaper and if it asks you to enable Active Desktop, so that was the problem
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
Need Web-based database administrator? You already have it!
|
|
|
|
|
ActiveDesktop is enabled.
I tried to change Wallpaper with
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, strFileName, SPIF_SENDCHANGE).
It changes wallpaper, but only if I choose 'Refresh' from desktop popup menu. If Classic Desktop enabled, this function works perfectly.
|
|
|
|
|
I know the problem.
I forgot to apply changes I made with IActiveDesktop::ApplyChanges.
|
|
|
|
|
Is there a way to use the cast operator L"test" with a CString object like
CString text = "test"; ?
|
|
|
|
|
Be careful about this. Depending on whether you're building for Unicode settings or not, CString s will hold exclusively Unicode (w_char based) or ANSI (char based) strings, but not both at the same time in the same program.
That said, if you want to transform a LPCSTR (const char * ) to a LPWSTR (w_char * ), have a look at the helper macro A2W (valid both in MFC and ATL.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
Just be careful with A2W() because it uses the stack for the conversion, so it's very dangerous to use in loops or with large strings. If you use VC7, try to take a look at CA2W(), it uses the heap (if needed), and is safe to use in loops
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
When I create a new dialog class and display it with the DoModal() command, I can't interact with anything else on the screen until I close the dialog. How do I create a dialog that will stay up on the screen and allow me to still access everything else (menus, etc in my actual MDI, SDI application). Similar to the properties dialog in visual studio.
|
|
|
|
|
A Modal dialog locks down the user interface until the user exits the dialog. When you call DoModal, you are creating a Modal dialog.
You want to create a Modeless dialog. You can do this by declaring an instance of your dialog, calling the Create method, then calling the ShowWindow method and setting the dialog to visible.
When you want this dialog to disappear, you can call ShowWindow again to hide the dialog.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
try to create the dialog object using the create command(supplying the parent handle). This creates a Modalless dialog box
|
|
|
|
|
http://www.codeproject.com/useritems/gettingmodeless.asp
Nish
Check out last week's Code Project posting stats presentation from :-
http://www.busterboy.org/codeproject/
Feel free to make your comments.
|
|
|
|
|
I want to add a variable for an edit box. But the only choices are CString, int, long, UINT... is there some way I can have the variable be a float or a double?
|
|
|
|
|
Yep! Do it the real way . Tell ClassWizard to use a Control instead of a Variable, and then manipulate the CEdit directly. You will need to call its SetWindowText() and GetWindowText() functions and do the appropriate float <-> string conversions.
cheers,
swinefeaster
Check out Aephid Photokeeper, the powerful digital
photo album solution at www.aephid.com.
|
|
|
|
|
Anyone know of the "right" way to format a number in C++ (i.e. using STL)
I have looked up the locale and facet classes but have yet to find an obvious answer/example for some like converting the number 1232344 into "1,232,344"
Any help would be greatly appreciated !
Thanks
|
|
|
|
|
This is one of the most intricate aspects of C++, and it involves locales, which are very often skipped in most books, even Stroustrup's "The C++ Programming Language". this Usenet post shows how to do it.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
Hi,
I am very new to C++ & have again come unstuck!
I am trying to copy a file from a file selected from an open file dialog to a fixed location & name. The from (open dialog etc) works fine but the destination part dose not:
CopyFile(m_File_In, "c:\\osc_out\\logo.*", FALSE);
I guess this is becouse my destination is not 'null terminated'?
I still get problems if i try:
CString m_File_Out;
m_File_Out="c:\\osc_out\\logo.*";
CopyFile(m_File_In, m_File_Out, FALSE);
If this is becouse it is not null terminated how do i do that?
Thanx
An Expert is somone who has previously made ALL the Mistakes, I dream of this day. - Lucky
|
|
|
|
|
You can only copy one file at a time. Wild card characters are not valied (*).
declaring a string in quotes "", the compiler automatically NULL terminates it for you. Besides you are using a CString so that would NULL terminate it as well.
You will need to change:
m_File_Out="c:\\osc_out\\logo.*";
To something else like:
m_File_Out="c:\\osc_out\\logo.bmp";
Or whatever file type it is because the asterisk (*) is not a legal character to use in a file name.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Thank you v.much. I will try that.
Thanx again,
Lucky
An Expert is somone who has previously made ALL the Mistakes, I dream of this day. - Lucky
|
|
|
|
|
To expand on what kilowatt said, you can use the splitpath() function to get the file extension from m_File_In.
HTH
---
CPUA 0x5041
Sonork 100.11743 Chicken Little
If a man is standing in the middle of the forest speaking and there is no woman around to hear him...is he still wrong?
|
|
|
|
|
Thank you v.much, thats the answer i was lookin for. I will try that.
Thanx again,
Lucky
An Expert is somone who has previously made ALL the Mistakes, I dream of this day. - Lucky
|
|
|
|
|
How do I create a horizontal line on a dialog box? Much like the horizontal line you can add to a menu. I've tried using a group box without caption text with a width of 1. The result is each end has one pixels worth of a corner which is not desirable.
Thanks in advance,
Bob
|
|
|
|