|
I want to detect when a user closes a window by clicking on the X in the title bar. I dont know how to create a message map to catch the event. When I close the Window, I want to delete the CWnd object associated with that Window.
Thanks.
Jerry
|
|
|
|
|
Handle WM_SYSCOMMAND , specifically the SC_CLOSE case.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
jerry1211a wrote:
I want to detect when a user closes a window by clicking on the X in the title bar.
Handle the WM_CLOSE message (CWnd::OnClose() ).
jerry1211a wrote:
When I close the Window, I want to delete the CWnd object associated with that Window.
If you are doing this from the window that is being closed, then the proper place to do it is in the PostNcDestroy() function
void CMyWindow::PostNcDestroy()
{
delete this;
}
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
Hi
Anyone knows that there is such tranlation tool exists or not. This translation tool can read a exe file's resource text and write back the translted text to the exe file.
Thanks,
|
|
|
|
|
Resource translation is big business - I doubt you'll find a robust mechanical solution. That being said, check out the translator example in this[^] article.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
the question is about a poker game.....i need to finish the check function to check whether it won or not!!!! the question is ....have to draw 5 cards and check win or not!... need help
Winning Conditions
// To be implemented in check_winnings
Combination Winnings Winning Status
Nothing 0 0
3 of a kind Bet * 5 100
4 of a kind Bet * 10 200
BONUS : Each 2 of a kind Bet * 8 300
BONUS : Straight Bet * 50 400
BONUS : Flush Bet * 100 500
BONUS : Royal Straight Flush Bet * 500 600
|
|
|
|
|
koalacui wrote:
i need to finish the check function...
Which implies that you have started it but have run into a snag. What exactly is troubling you? The more specific you are, the more help you'll potentially receive.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
more details:
/* Sample Output 1////////////////////////////////////////////////
========================================
Your current balance is $100 dollars.
========================================
Please enter the amount to bid: 150
ALERT! You do not have enough to bet $150.
Please enter the amount to bid: 90
========================================
Your current balance is $10 dollars.
========================================
Please [ENTER] to draw your first card …
-- Your Cards on hand ------------------
- A of Spades
----------------------------------------
Please [ENTER] to draw your second card …
-- Your Cards on hand ------------------
- A of Spades (61)
- 10 of Spades (70)
----------------------------------------
Please [ENTER] to draw your third card …
-- Your Cards on hand ------------------
- A of Spades (61)
- 10 of Spades (70)
- K of Spades (73)
----------------------------------------
Please [ENTER] to draw your forth card …
-- Your Cards on hand ------------------
- A of Spades (61)
- 10 of Spades (70)
- K of Spades (73)
- J of Spades (71)
----------------------------------------
Please [ENTER] to draw your last card …
-- Your Cards on hand ------------------
- A of Spades (61)
- 10 of Spades (70)
- K of Spades (73)
- J of Spades (71)
- Q of Spades (72)
----------------------------------------
== Winning Result ======================
Congratulation, you have a Royal Flush!!
You have won $2000 dollars.
========================================
|
|
|
|
|
#include <iostream>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <conio.h>
using namespace std;
void print_balance( int ) ;
void print_result( int ) ;
void Print_Cards_At_Hand ( void ) ;
void Check_Winning ( void ) ;
int draw_Card( void ) ;
int deck[52] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73 } ;
void main( void )
{
srand (time (0));
int balance = 100 ;
int bet = 0 ;
while( balance > 0 )
{
balance = balance - bet;
print_balance( balance ) ;
cout << endl ;
if (balance != 0)
{
do
{
cout << "Please enter the amount to bid: $" ;
cin >> bet ;
if( bet > balance )
{
cout << "ALERT! You do not have enough " << "to bet $" << bet << endl ;
}
cout << endl ;
}while( bet > balance || bet == 0) ;
Print_Cards_At_Hand();
cout << endl ;
}
}
} // main()
void print_balance( int balance )
{
cout << "========================================" << endl;
cout << "Your current balance is $" << balance << " dollars" ;
cout << endl ;
if( balance <= 0 )
{
cout << "You are bankrupted" ;
cout << endl;
}
cout << "========================================" << endl;
}
void print_result( int winning_amt )
{
cout << "== Winning Result ======================" << endl;
if( winning_amt > 0 )
{
cout << "You have won " << winning_amt << "dollars."
<< endl ;
}
else
{
cout << "Sorry, you have not won anything." << endl ;
cout << "You have lost $" << winning_amt << " dollars." ;
}
cout << "========================================" << endl;
}
int draw_Card( void )
{
int c = (rand() % 52) ;
return c;
}
void Print_Cards_At_Hand ( void )
{
int i;
int x;
int y;
int number[6];
int identity[6];
int value[6];
string type;
for (i=1;i<6;i++)
{
cout << "Press [ENTER] to draw your " << i << " card ... " << endl;
while (_getch() !=13)
{}
cout << "-- Your Cards on hand ------------------" << endl;
int card_index = draw_Card();
y = deck[card_index]/20;
if( y == 0 )
{
identity[i] = 1;
value[i] = deck[card_index];
number[i] = deck[card_index];
}
else if( y == 1 )
{
identity[i] = 2;
value[i] = deck[card_index];
number[i] = deck[card_index] - 20;
}
else if( y == 2 )
{
identity[i] = 3;
value[i] = deck[card_index];
number[i] = deck[card_index] - 40;
}
else
{
identity[i] = 4;
value[i] = deck[card_index];
number[i] = deck[card_index] - 60;
}
for (x=1;x<=i;x++)
{
if ( identity[x] == 1 )
{
cout << "- " << number[x] << " of Diamonds" << " ("<< value[x] << ")"<< endl;
}
else if ( identity[x] == 2 )
{
cout << "- " << number[x] << " of Clubs" << " ("<< value[x] << ")"<< endl;
}
else if ( identity[x] == 3 )
{
cout << "- " << number[x] << " of Hearts" << " ("<< value[x] << ")"<< endl;
}
else
{
cout << "- " << number[x] << " of Spades" << " ("<< value[x] << ")"<< endl;
}
}
}
}
void Check_Winning ( void )
{
}
|
|
|
|
|
How to get last access time of some directory?
On files, I use GetFileTime() function and it is
working property, but on folder, it returns null.
Thanks in advanvce.
|
|
|
|
|
MirkoMax wrote:
...but on folder, it returns null.
And what does GetLastError() return?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I am a beginner in the windows programming world, and am having a bit of trouble figuring out how to determine the state of my checkbox when it's ownerdraw.
If I use BM_GETCHECK it always returns 0, even if I send BM_SETCHECK a line above passing BST_CHECKED. I also tried ORing BS_CHECKBOX and/or BS_AUTOCHECKBOX with BS_OWNERDRAW but BM_GETCHECK still returned 0.
I then attempted to use BM_SETIMAGE as general storage (a pointer) but BM_GETIMAGE always returns 0 as well.
Is it due to the fact my checkboxes are ownerdraw, or is there some other problem I'm unaware of?
thanks
|
|
|
|
|
May we see a code snippet?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
hTempWnd = CreateWindowEx (
0,
"Button",
"Compression",
WS_VISIBLE | WS_CHILD | BS_OWNERDRAW,
clientRect.right - MM_DBUTTON_WIDTH - MMPADDING_RIGHT,
clientRect.top + MMPADDING_TOP + MM_GROUPPADDING_BOTTOM,
MM_DBUTTON_WIDTH, MM_DBUTTON_HEIGHT,
hWnd,
(HMENU) MMENU_BUTTON_COMPRESSION,
GetModuleHandle ( NULL ),
NULL
) ;
LPDRAWITEMSTRUCT lpdis from lParam in WM_DRAWITEM
long lResult = 0;
lResult = SendMessage ( lpdis->hwndItem, BM_GETCHECK, (WPARAM) 0, (LPARAM) 0 ) ;
if ( lResult == BST_CHECKED ) ...
When I was trying BM_GETIMAGE I used the same procedure as the second code snippet
edit: It seems that BM_GETCHECK and BM_SETCHECK just don't work with ownerdraw, so that solves that issue, but I'm still unsure why BM_SETIMAGE doesn't work.
|
|
|
|
|
What happens if you create a checkbox like:
CreateWindowEx(..., WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX, ...); In other words, does the owner-draw style have any affect? I wouldn't think so but I'm just trying to pare the problem down.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
I have tried using BS_AUTOCHECKBOX with BS_OWNERDRAW (I do draw them myself so I need that) but it doesn't seem to have an effect, and BM_GETCHECK still always returns 0.
|
|
|
|
|
c. s. wrote:
I have tried using BS_AUTOCHECKBOX with BS_OWNERDRAW (I do draw them myself so I need that) but it doesn't seem to have an effect...
Right, but does the problem persist for non owner-drawn checkboxes?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
c. s. wrote:
hTempWnd = CreateWindowEx (
0, // no extended style
"Button",
"Compression", // toggles chunk compression
WS_VISIBLE | WS_CHILD | BS_OWNERDRAW, // make a visible child window, that we draw ourself (see void DrawCheckbox)
clientRect.right - MM_DBUTTON_WIDTH - MMPADDING_RIGHT, // create it near the top right corner
clientRect.top + MMPADDING_TOP + MM_GROUPPADDING_BOTTOM,
MM_DBUTTON_WIDTH, MM_DBUTTON_HEIGHT, // use our standard checkbox button height and width
hWnd, // our parent window is this popup menu
(HMENU) MMENU_BUTTON_COMPRESSION,
GetModuleHandle ( NULL ),
NULL // pass no extra parms on creation
) ;
According to this[^], an owner-drawn button "has no predefined appearance or usage. Its purpose is to provide a button whose appearance and behavior are defined by the application alone."
Furthermore, your call to Create isn't even specifying one of the possible check box styles (BS_CHECKBOX, BS_AUTOCHECKBOX, BS_3STATE, BS_AUTO3STATE), so it's no wonder the control doesn't react to BM_SETCHECK messages. Try adding BS_CHECKBOX, and if that doesn't work (which may be due because of the owner draw style), I suggest subclassing the control so that you can handle the BM_GETCHECK and BM_SETCHECK messages yourself.
Hope that helps,
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Jose Lamas Rios wrote:
Furthermore, your call to Create isn't even specifying one of the possible check box styles (BS_CHECKBOX, BS_AUTOCHECKBOX, BS_3STATE, BS_AUTO3STATE), so it's no wonder the control doesn't react to BM_SETCHECK messages.
Did you miss this:
"I also tried ORing BS_CHECKBOX and/or BS_AUTOCHECKBOX with BS_OWNERDRAW but BM_GETCHECK still returned 0."
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
DavidCrow wrote:
Did you miss this:
"I also tried ORing BS_CHECKBOX and/or BS_AUTOCHECKBOX with BS_OWNERDRAW but BM_GETCHECK still returned 0."
Yes, I missed it. Sorry.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
I was hoping to avoid using my own storage, but it seems not too feasible.
I will subclass it and see how it turns out, thanks all.
|
|
|
|
|
c. s. wrote:
I was hoping to avoid using my own storage, but it seems not too feasible.
I will subclass it and see how it turns out, thanks all.
Well, subclassing it would have an additional benefit, since it would allow you to handle the drawing in the control, rather than doing so in the parent. That's in my opinion a better alternative because it's easier to reuse the control with different parents.
Good luck
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Greetings:
I have a simple ListCtrl box in Report mode. I want the parent window (a dialog) to be notified when any vertical scroll operations are requested.
I can't see anyway to do this. Is it a WM_NOTIFY? If so, which code ID is used?
Thank you,
Mark
|
|
|
|
|
|
Hi JLR, thanks for your response...
My application must support Windows down to Win 95. Is there anything I can do?
Mark
|
|
|
|
|