|
The list box that's part of the combo box has no parent (well, maybe the desktop). It has the style WS_POPUP.
Chris Richardson
C/C++ Include Finder[^]
|
|
|
|
|
I have a class with several members> Theres a deque of these CImage objects:
std::deque<CImage> myObj. At one place in my code I need a deque of a finite size n, which is loaded with n null CImage objects.
How do I make a null object? Just push_back ing (0) doesnt compile. SO do I need to do:
CImage myIMage = new CImage;
myImage.attributeA = 0;
myImage.ATtributeB = 0;
..
etc?
then do
for (int i = 0; i <n; i++)
myDeque.pushback(myImage);
delete myImage;
Appreciate your help,
ns
|
|
|
|
|
You need to store CImage pointers in the deque instead of CImage objects.
e.g. std::deque<CImage*> myObj;
Then you can store null pointers inside the deque as well as created CImage objects.
Dave
|
|
|
|
|
I'll look int othis and see if I can redesign...
Appreciate your help,
ns
|
|
|
|
|
Or add an IsValid() method to your CImage object.
Todd Smith
|
|
|
|
|
My problem is with pre-build events. I have a custom resource compiler that receives as input a directory name, then it compiles all custom resource files in that directory and generate a header (if different from the previous version). So I want my visual studio to ALWAYS run that command line, don't matter if it thinks the project is up to date... I've tried several things, but nothing works properly. The pre-build event never works right because it thinks the project is up-to-date and don't execute the pre-build.
Any help would be great on that
|
|
|
|
|
I can only recommend a sneaky solution:
1. Change the date of your computer to some time in the far future, say two years from now.
2. Take a source file (from the project) that you never change, open it, save it, and make it read-only.
3. Reset the date of your computer.
Now when you build your project, that file will always be recompiled, and your pre-build stuff should work.
Regards,
Alvaro
The world is a dangerous place, not because of those who do evil, but because of those who look on and do nothing. -- Albert Einstein
|
|
|
|
|
That data change trick works, I've tried before. The problem is that visual studio always says "The project configuration(s) are out of date, Would you like to build them?", which is very annoying. I wonder if there is another way... Maybe I'll have to create a custom tool and manually run it before the project compilation, but it's far from the ideal solution. And another problem is that other programmers will use this project.
|
|
|
|
|
Im wondering if you could get a command line/dos version of the 'touch' utility and set the dir/project files date to a previous date in the pre-build step (may need to fire off a batch file) - would that force visual studio to rebuild ?? .. its easier than continually changing the date on the computer ...
or build a quick and dirty 'touch' yourself, or use someone's cp article for a head-start...
'G'
|
|
|
|
|
How can i write a progarmm that resides background and replaces any predefined word that user types in with another word ?
|
|
|
|
|
Install a keyboard hook using the SetWindowsHook function (there are many articles here on CodeProject on how to do this).
Save all the characters you receive into a buffer.
When the last x chars are your word, use the keybd_event or SendInput functions to simulate backspaces and then your word.
This should work.
Another approach would be to get the handle of the current active window the user is typing in. When you have the handle you can get and set its text.
So get the text, look for the string, replace it, and set the controls text.
-Dominik
|
|
|
|
|
Hi, there:
I am trying to use MSChart to visualize some performance data.
But found out that the program only works fine on the machine
with MSVC installed.
Could anyone kindly tell me how to make a smallest installation
so that I can make other machine without MSVC see tha right
MSChart? (How to install the OCX to another machine?)
Thanks a lot in advnace
|
|
|
|
|
How does one change the desktop image in code? I would like to write a program that makes a desktop image containing the ip address of my system.
I have found what I think is the right value in the registry. I just need to be able to refresh the desktop to so the changes take effect.
Cheers,
Clint
|
|
|
|
|
This code gets the key, checks for a certain bitmap, loads the correct one, and then tiles it. Hope this helps
lResult = RegCreateKeyEx(HKEY_CURRENT_USER,
"Control Panel\\Desktop",
0,
"",
REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,
NULL,
&hKeyResult,
&dwDisposition);
if (lResult != ERROR_SUCCESS){
printf("Houston we have a problem\n");
}
lResult = RegQueryValueEx( hKeyResult,
"Wallpaper",
NULL,
&Type,
(unsigned char*)cTmpData, // address of data buffer
&cbData );
//
// If the background is NOT the correct one, then change the background
// to the appropriate one
//
if (strstr(cTmpData, "mypic.bmp") == NULL) {
//strcpy(cBuff,cXvision);
if (getenv("SystemDrive") != NULL)
sprintf(cBuff,"%s\\iux\\icons\\Amdatabg.bmp",getenv("SystemDrive"));
else
strcpy(cBuff,"C:\\icons\\mypic.bmp");
printf("background wallpaper is %s\n",cTmpData);
printf("should be %s\n",cBuff);
lResult = RegSetValueEx(hKeyResult,
"Wallpaper",
0,
REG_EXPAND_SZ,
(unsigned char*)cBuff,
lstrlen(cBuff));
if (lResult != ERROR_SUCCESS){
printf("Flordia we have a problem\n");
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
lResult,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
cBuff,
255,
NULL );
printf("error is %s\n",cBuff);
}
//
// now tile the wallpaper
//
strcpy(cBuff,"1");
printf("now tileing the wallpaper\n");
lResult = RegSetValueEx(hKeyResult,
"TileWallpaper",
0,
REG_SZ,
(unsigned char*)cBuff,
lstrlen(cBuff));
if (lResult != ERROR_SUCCESS){
printf("Flordia we have a problem\n");
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
lResult,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
cBuff,
255,
NULL );
printf("error is %s\n",cBuff);
}
}
Dan Willis
|
|
|
|
|
Thanks, I haven't tried it out yet but will it automatically update the background or do I need to restart the system? I would also assume that I woulnd't set "TileWallpaper" if I didn't want that option, but rather just show the image centered.
Cheers,
Clint
|
|
|
|
|
I don't remember off hand. You'll have to check on that
Dan Willis
|
|
|
|
|
Off the top of my head (no copy of MSDN kicking about) i think u should be able to use the API SystemParametersInfo
Should work something like:
<br />
if( SystemParametersInfo( SPI_SETDESKWALLPAPER, 0, ( PVOID ) TEXT( "background.bmp" ), SPIF_SENDCHANGE | SPIF_UPDATEINIFILE ) == TRUE )<br />
{
<br />
}<br />
|
|
|
|
|
How Do i programmatically select a specific row in the MSFLexgrid ?
|
|
|
|
|
Hi Maak!
Thank you for the code it works but... with an error..
First!
Could you tell me what "index++;"
"index = index < 4 ? index : 0;"
means???, the "index++" i understand, but the "index = index < 4 ? index : 0;" i don't...
Second!
I change a bit the code like...
.............................
index++;
index = index < 10 ? index : 0;
if (index == 9)
{
index = 1;
}
.............................
I think you understand...
it displays 8 bitmaps again and again with a loop!
The problem is: if i press the button several times
and i see the bitmaps from the beginning then a messagebox is displayed:
" this program has performed an illegal operation ...........", you know!
Then another message box "Unhandled exception.....0xC0000005. Access violation!"
What's wrong.....
|
|
|
|
|
Take a look at the ? operator
saying
index = (index < 10) ? a : b;
if (index < 10)
index = a;
else
index = b;
So its a quick short hand form of an if/else
As to your other problem, not too sure...
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
|
Dennis L wrote:
index = index < 4 ? index : 0;
Time to revisit your C/C++ book. This is the ternary operator, which is basically an "inline if statement". It's equivalent to:
if (index < 4)
index = index;
else
index = 0;
In this case it would have been clearer to just say:
if (index >= 4)
index = 0;
Regards,
Alvaro
The world is a dangerous place, not because of those who do evil, but because of those who look on and do nothing. -- Albert Einstein
|
|
|
|
|
Thanks for the explanation!
But What is that error i refered to before???
|
|
|
|
|
That's OK!
I fixed the problem....
I forgot to free() something..
Thanks Anyway!
|
|
|
|
|
Hi,
I have problems getting the Open/Save as common dialogs of an application to work under NT4. The project was compiled under Win2k/XP and VC++ 7.0, and the associated deployment project has detected all dependencies among the .msm packages, and installs them sucessfully in the target computer.
Does anybody knows the trick? Any suggested idea is welcome.
Thanks
|
|
|
|
|