|
MohammadAmiry wrote: I need to hide some windows using ShowWindow API using 0x0 flag.
Why are you not using SW_HIDE ?
MohammadAmiry wrote: But the problem is
that I when I set the flag to show windows, I should set it to SW_MINIMIZE, SW_NORMAL, SW_MAXIMIZE...
How do you propose to set a window to both minimized and maximized?
MohammadAmiry wrote: What I need is to show them in the window state that they were before hiding.
Use IsIconic() and IsZoomed() .
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
MohammadAmiry wrote: What I need is to show them in the window state that they were before hiding.
ShowWindow(SW_SHOW);
should do.
- It's easier to make than to correct a mistake.
|
|
|
|
|
Thank you!
Worked perfect...
|
|
|
|
|
Dear all,
I'm using some GDI+ functions in my project. Is there any way to let my program start peacefully if file gdiplus.dll is not available (of course, some functionalities should be disabled)?
By other words, I want to load this dll dynamically. If file gdiplus.dll is unavailable, some functionalities will be disabled and the program should start normally.
Thanks in advance.
Regards,
|
|
|
|
|
Refer to LoadLibrary as mentioned in this article[^].
Maxwell Chen
|
|
|
|
|
Thanks,
Do you know any articles explicitly written about using GDI+ dynamically?
Regards,
|
|
|
|
|
|
Tuan Dang wrote: start peacefully if file gdiplus.dll is not available (of course, some functionalities should be disabled)?
With or without GDI+, your app should start peacefully.
You probably don't want to load GDI+ dynamically, as GDI+ (like GDI) is pretty much a programming model. Although you may mix GDI with GDI+ to some extent, people usually avoid doing so. Unless there is some absolute reason that you have to mix them together, a good practice is to load GDI+ statically. This way it won't create any complexity to your app.
- It's easier to make than to correct a mistake.
|
|
|
|
|
Jun Du wrote: people usually avoid doing so
That's quite a statement to make. Do you think you just made that up? Maybe?
|
|
|
|
|
If you think people should mix GDI and GDI+ in their design, make an argument why you think so. I've used both a lot and it's certainly debatable.
- It's easier to make than to correct a mistake.
|
|
|
|
|
Jun Du wrote: With or without GDI+, your app should start peacefully.
Is it true?
When starting in Windows 2000 (in which gdiplus.dll is unavailable), my program caused an error saying that "The dynamic link library gdiplus.dll could not be found in the specified path...". Then it terminated.
With that error, I don't think we can say the program starts peacefully.
My question is that do we have any ways to smartly use GDI+ functions only when its DLL is avaialabe. Otherwise, all program's functionalities related to GDI+ should be quietly and programmatically disabled.
I realize that whether the GDI+ functions are actually called or not, file gdiplus.dll is always required.
Thanks y'all. Unfortunately, my problem has still unsolved yet.
Regards,
|
|
|
|
|
I think I know your situation better now. The issue should be resolveable.
Tuan Dang wrote: Jun Du wrote:
With or without GDI+, your app should start peacefully.
Is it true?
Yes. It's your respossibility to handle this more properly.
Tuan Dang wrote:
When starting in Windows 2000 (in which gdiplus.dll is unavailable), my program caused an error saying that "The dynamic link library gdiplus.dll could not be found in the specified path...". Then it terminated.
With that error, I don't think we can say the program starts peacefully.
If the app was linked to gdiplus.lib, it will look for the corresponding DLL at the start-up. That's how it works. You've already realized that, as you stated in the following:
Tuan Dang wrote: I realize that whether the GDI+ functions are actually called or not, file gdiplus.dll is always required.
But even you dynamically load the DLL, your app has no clue whether the DLL is present or not.
Tuan Dang wrote: My question is that do we have any ways to smartly use GDI+ functions only when its DLL is avaialabe. Otherwise, all program's functionalities related to GDI+ should be quietly and programmatically disabled.
Yes. I can think of two options:
1) Include gdiplus.dll in your final deliverables. I've noticed many venders do this and a couple of CP articles do so as well.
2) Add code to check if gdiplus.dll exists in the target computer. I remember it's part of Platform SDK for Winows 2000 (SDK 2003?). To guarantee that you can load, you also may include in the documentation that the target machine must have a recent Platform SDK installed.
Hope this helps.
- It's easier to make than to correct a mistake.
|
|
|
|
|
Jun Du wrote: target machine must have a recent Platform SDK installed
That's absurd!
The GDI+ redistributable for pre-XP boxes can be found at
GDI+ Redistributable[^]
It's a slight bit smaller methinks
|
|
|
|
|
|
Hi,
I am coding a program in vc++6. I have a wizard with 5 property pages. There is an edit box on each page.
Each time text is entered in the edit box and a button called Add is pressed, the text is listed in a listbox.
I want the text to be entered in the list box when the Enter key is pressed.
I used the PreTranslateMessage to capture the Enter key and after that, I am assiging the tab key to it. But i do not want that to happen.
If i do not assign the tab key, the wizard goes to the next page of the property sheet How do I not let it happen.
BOOL CSelectPayroll_PP2::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message== WM_KEYDOWN && pMsg->wParam==13)
{
OnAdd() ;
pMsg->wParam=9;
}
return CPropertyPageEx::PreTranslateMessage(pMsg);
}
Thanks,
Tara
Fortitudine Vinsinues!
|
|
|
|
|
I wouldn't recommend to alter the message type; rather discard it after it's handled. Have you tried to change
return CPropertyPageEx::PreTranslateMessage(pMsg);
to
retrun TRUE;
- It's easier to make than to correct a mistake.
|
|
|
|
|
I had tried it. With retutrn TRUE that page appears blank.
With return FALSE it acts as usual i.e. it goes to the next page.
Is there any thing else that may be done?
Fortitudine Vinsinues!
|
|
|
|
|
I got it!!
BOOL CSelectPayroll_PP2::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message== WM_KEYDOWN && pMsg->wParam==13)
{
OnAdd() ;
pMsg->hwnd= NULL;
}
return CPropertyPageEx::PreTranslateMessage(pMsg);
}
Fortitudine Vinsinues!
|
|
|
|
|
Hey guys!
I have been working on my random combinor for a while now, and I want to take it to the next level.
The thing actually does this:
It has two arrays of strings, one being filled with names, the other being filled with activities that a person can do.
The program then randomly generates a number (1-9, where 9 is the amount of strings in both arrays) and displays the corresponding name/action.
E.g. "Kim" + " is working in the garden" = Kim is working in the garden.
(You can find the source underneath here, in case you need it)
Now, I want the program to EXCLUDE already used options.
For instance, in my exapmle, the name "Kim" and the activity " is working in the garden." will not be used anymore.
How can I do this? I thought of creating integers carrying or either the value 1 or 0 and when the program generates the random numbers it's going to check that value (0 means the name or activity has not yet been used)and turn it into 1 and proceed, or try another one when it's 1 until he finds one with 0.
But the problem is I don't know how to do this, unless by creating a lot of code, which is too ineffecient to me.
Does anyone have any ideas?
Thanks in advance!
random_activities.cpp<br />
#include < cstdlib ><br />
#include < ctime ><br />
#include < iostream ><br />
#include < string ><br />
using namespace std;<br />
<br />
int main()<br />
{<br />
<br />
string person[9] = {<br />
"Jason",<br />
"My best friend",<br />
"Uncle Ben",<br />
"Mark",<br />
"Eva",<br />
"Dad",<br />
"My daughter",<br />
"Deborah",<br />
"That kid over there"};<br />
<br />
string activity[9] = {<br />
" is preparing a diner for two.",<br />
" is playing a game of tennis with mum.",<br />
" is making out with his/her girl/boyfriend.",<br />
" is studying his geography exam.",<br />
" is still sleeping.",<br />
" is cruising on his motorcycle.",<br />
" is shooting baskets in the garden.",<br />
" is relaxing by the pool.",<br />
" is coding a simple program in C++"};<br />
<br />
int a = 0;<br />
int b;<br />
int i;<br />
int j;<br />
const int N = 9;<br />
<br />
cout << "Who is doing what? Find out with this program!\n";<br />
<br />
cout << "Of how many persons would you like to know what they are doing?\nThey might be busy doing more things at a time, though!\n"; <br />
<br />
cin >> b;<br />
<br />
cout << endl;<br />
<br />
srand( (unsigned)time( NULL ) );<br />
<br />
while (a < b){<br />
<br />
i = rand() % N;<br />
j = rand() % N; <br />
cout << person[i] << activity[j] << endl; <br />
a++;<br />
<br />
}<br />
<br />
cout << "\n\nNow you know a bit more about the people around you!\nCome back later, you hear!";<br />
<br />
getchar();<br />
<br />
return 0;<br />
<br />
}
|
|
|
|
|
try this... Declare a struct first with the string resources
struct StringResource{
string person[9] = {
"Jason",
"My best friend",
"Uncle Ben",
"Mark",
"Eva",
"Dad",
"My daughter",
"Deborah",
"That kid over there"};
string activity[9] = {
" is preparing a diner for two.",
" is playing a game of tennis with mum.",
" is making out with his/her girl/boyfriend.",
" is studying his geography exam.",
" is still sleeping.",
" is cruising on his motorcycle.",
" is shooting baskets in the garden.",
" is relaxing by the pool.",
" is coding a simple program in C++"};
};
In your main program call the struct:
StringResource bunchostrings;
Everytime a string is used just empty the values. Ex:
bunchostrings.activity[8] = "";
Check to see if the string is empty, if it isnt, use it then after empty it. If the string is empty, then randomly search for another one.
Hope that helps,
Robbie
|
|
|
|
|
Here's how I'd do it:
#include <algorithm>
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
typedef const char* PCSTR;
PCSTR names[] =
{
"Bob",
"Jane",
"Tina",
"Bill"
};
PCSTR* names_end = names+sizeof(names)/sizeof(names[0]);
PCSTR tasks[] =
{
"is laughing",
"is crying",
"is jumping",
"is having fun"
};
PCSTR* tasks_end = tasks+sizeof(tasks)/sizeof(tasks[0]);
random_shuffle(names, names_end);
random_shuffle(tasks, tasks_end);
for (
PCSTR *pName=names, *pTask=tasks;
pName!=names_end && pTask!=tasks_end;
++pName, ++pTask )
{
cout << *pName << " " << *pTask << "." << endl;
}
return 0;
}
Steve
|
|
|
|
|
luckily I read your post before I replied - yep, gotta love those stl Algorithms like random_shuffle .. I found stl took a while to get the hang of, but it sorta grows on me now ..
'g'
|
|
|
|
|
another way would be to create a 9x9 array of bool values:
bool used[9][9];
for (int z=0;z<9;z++) for (int q=0;q<9;q++) used[z][q]=false;
then, when you choose i,j make sure that pair hasn't been used:
int tested=0;
while (used[i][j] && tested<9*9)
{
.. choose new i,j
tested++;
}
then, when you know your i,j haven't been used, set the appropriate used flag to true
used[i][j] = true;
maybe not ideal, but it's an option.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
can we use these when designing an MFC application?
it keeps telling me:
error C2065: 'HDEVINFO' : undeclared identifier
-AND-
error C2065: 'SP_DEVICE_INTERFACE_DATA' : undeclared identifier
I've #included the following:
#include <stdlib.h>
#include <objbase.h>
#include <setupapi.h>
#include <winioctl.h>
#include <process.h>
#include <memory.h>
#include "stdafx.h"
Could someone tell me what i'm doing wrong... or if I need to drink more coffee...
Kitty5
|
|
|
|
|
Do you have the following line?
#include <setupapi.h>
|
|
|
|
|