|
Alton Williams wrote:
delete pSelector;
You are destroying immediatly the dialog box you have created. Destroy the object in CColourSelection::PostNcDestroy instead.
void CColourSelection::PostNcDestroy()<br />
{<br />
delete this;<br />
}
Silence Means Death
Stand On Your Feet
Inner Fear
Your Worst Enemy
|
|
|
|
|
KaЯl wrote:
Destroy the object in CColourSelection::PostNcDestroy instead.
I've tried that but dialog is still not opening.
KaЯl wrote:
void CColourSelection::PostNcDestroy()<br />
{<br />
delete this;<br />
}
I want to extract values from dialog object priorto destruction in my CFormView class. Hence, it's not appropiate for CColourSelection to "commit suicide".
|
|
|
|
|
Alton Williams wrote:
I've tried that but dialog is still not opening
You have also to call pColourSelection->ShowWindow(SW_SHOW);
Are you sure the problem doesn't come from your CColourSelection class?
Alton Williams wrote:
Hence, it's not appropiate for CColourSelection to "commit suicide".
It's not exactly a suicide. The PostNcDestroy method is called after the destruction of the dialog box (destruction != deleting). This method allows to free the memory you've allocated with the new CColourSelection .
Check your mail, I've send a small app showing the use of a modeless dialog.
HTH,
K.
Silence Means Death
Stand On Your Feet
Inner Fear
Your Worst Enemy
|
|
|
|
|
How do I make them disappear...
I've tried:
cs.dwStyles = ~ WS_VSCROLL;
But it causes the framework to not create a document or something like that...
Any ideas how I can go abouts doing this...?
Thanks
Cheers
I'm drinking triples, seeing double and acting single
|
|
|
|
|
Are you sure the scrollbars are carried by the CMDIChildFrame, and not by the embedded view contained in the Child Frame?
What kind of view do you use?
Silence Means Death
Stand On Your Feet
Inner Fear
Your Worst Enemy
|
|
|
|
|
1. I have a simple dialog window, which has the "minimize" box enabled; the "maximize" box is not enabled.
2. One of the buttons of my mouse is customized as "maximize". Pressing this button maximizes the above, "non-maximizable" window.
Is there a direct, clean way to prevent this maximizing? I guess posting a WM_SIZE message with SIZE_RESTORED from OnSize would work, but I find it strange that a "no" won't be taken as "no".
|
|
|
|
|
Catch the WM_SIZE:
OnSize( UINT nType, int cx, int cy );
if nType==SIZE_MAXIMIZED don't let the message go further.
Mickey
|
|
|
|
|
Thanks; however this does not help. The OnSize description states:
The framework calls this member function AFTER the window's size has changed.
I fact, this filtering in OnSize does not change the result. A call of CDialog::OnSize will be generated by the wizzard in OnSize. I admit that I don't know, what CDialog::OnSize does (this will be generated by the wizzard in OnSize), but no matter if I call it or not, the result is the same.
In the meantime I tested my own suggestion, posting a WM_SIZE message with SIZE_RESTORED. This does not work either; I'd like to know, why. The message goes through properly, it appears in OnSize as well, with the identical parameters, as a RESTORE from the minimized state generates - but restoring does not happen.
SetWindowPlacement works, but that needs more preparation: not only the size, but the position of the last non-maximized window too has to be recorded. Not a big deal, but all this is nonsense.
|
|
|
|
|
Have you tried to catch WM_WINDOWPOSCHANGING[^]?
Silence Means Death
Stand On Your Feet
Inner Fear
Your Worst Enemy
|
|
|
|
|
You must also process the CWnd::OnGetMinMaxInfo or handle WM_GETMINMAXINFO.
If that does not work, override CWnd::PreTranslateMessage and trap the sizing calls.
The memories of a man in his old age are the deeds of a man in his prime.
|
|
|
|
|
Thanks for the suggestions.
WM_WINDOWPOSCHANGING appears a good solution, but it does not say, when the window will be maximized, i.e. it would need a "calibration" to get the actual maximum size.
In the meantime I solved the problem already, with a combination of OnSize and OnMove plus SetWindowPlacement as correction of MAXIMIZE. However it is not a nice solution. Sometimes OnSize, sometimes OnMove is the first, when both will be called. Lots of work-around only to prevent the system from doing something, what it should not do per definition.
Anyway, now it's working, but I'm now trying Blake's suggestion, GetMinMaxInfo. This function gets called before each MAXIMIZE (I have expected a call at MINIMIZE at well, even though it does not matter in my case). Simply to prevent MAXIMIZE to a large size is very simple this way. However, there is still a small problem: it positions the window to the upper left corner; one has to work around it.
Once more, thanx for the help.
|
|
|
|
|
int nTemp;
nTemp=0xe;
My aim is to put a hex value to a int varalbe "nTemp".
As a result, the real value is 0 after those are executed.
Can a int varable receive a value like 0xe directly?
|
|
|
|
|
|
Now the varable can get its right value.
Maybe something is wrong with my VC6,isn't it?
Thanks!
|
|
|
|
|
Hi,
I have a source code tree (C++) traditionaly compiled in unix Makefiles. I want to create a project in VC++ so that I can view the source code easily.
Is there some easy way to create a project (dsw file) for the whole tree (>100 files C++ in >15 directories).
Thanks
John
|
|
|
|
|
Visual Studio can open .MAK files. If .MAK files are in a standard format, it shouldn't be a problem. Otherwise, if they are compiler dependent, I guess manually creating the projects will be necessary.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Hi,
need to know how to draw a text string in the center of client area.
regards
|
|
|
|
|
sorry, i found it
GetClientRect(hWnd, &rc);
DrawText(hdc, "Text", 4, &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
|
|
|
|
|
Hi,
I have a main dialog that has a tab control. For each tab, I have a child dialog. The problem is that the tab control's color isn't solid (with XP styles), so if I use COLOR_WINDOW for the child window, it will not take the gradient pattern of the tab control.
How can I manage to make this work?
Thanks!
---------------
Tired of Spam? InboxShield for Microsoft® Outlook® 2K/2K2/2K3
http://www.inboxshield.com
|
|
|
|
|
Found it!
Take a look at the EnableThemeDialogTexture() function!
---------------
Tired of Spam? InboxShield for Microsoft® Outlook® 2K/2K2/2K3
http://www.inboxshield.com
|
|
|
|
|
I copy these sample codes from MSDN:
if (!ReleaseSemaphore(
hSemaphore, // handle to semaphore
1, // increase count by one
NULL) ) // not interested in previous count
{
// Deal with the error.
}
But what can I do to Deal with the error. And what will cause ReleaseSemaphore Error?
Thank you!
Let's roll!
|
|
|
|
|
call GetLastError() to find it out!
Don't try it, just do it!
|
|
|
|
|
This is what I have to work with... I have a program of tic tac toe that is in the console, command prompt , and the board is an array and have everything finished up to the point of getting the computer move. I am trying first to make the computer do random moves and then record to a seperate file, one for each win, lose, and draw and learn from which moves were good and which weren't as good. So far I have the below: (please help)
#include <iostream>
#include <fstream>
using namespace std;
char matrix [3][3]; //Tic Tac Toe Matrix
char check();
void init_matrix();
void get_player_move();
void get_computer_move();
void disp_matrix();
void f_matrix();
fstream SaveFile("wx.txt",ios::in | ios::out | ios::trunc);
fstream SaveFile2("wo.txt",ios::in | ios::out | ios::trunc);
int main()
{
char done = ' ';
init_matrix();
do
{
disp_matrix();
get_player_move();
done = check(); //See if any winner
f_matrix();
if(done != ' ')
{
break; //Winner!!!
}
get_computer_move();
done = check(); //See if any winner again
f_matrix();
} while(done == ' ');
disp_matrix(); //Display final matrix
if(done=='X')
{
SaveFile << "winner X\n;" << endl;
cout << "You won!\n";
}
else
{
SaveFile2 << "winner O\n;" << endl;
cout << "I won!!!!\n";
}
// f_matrix(); //Write to file final matrix / result
SaveFile.close();
SaveFile2.close();
return 0;
}
//Initialize the matrix
void init_matrix()
{
int i, j;
for(i=0; i<3; i++)
for(j=0; j<3; j++) matrix[i][j] = ' ';
}
//Get the player's move
void get_player_move()
{
int x, y;
cout << "Enter X,Y coordinates for your move: ";
cin >> x;
cin >> y;
x--; y--;
if(matrix[x][y]!= ' ')
{
cout << "Invalid move, try again.\n";
get_player_move();
}
else
{
matrix[x][y] = 'X';
}
}
//Get a move from the computer
void get_computer_move()
{
int i, j;
do
{
i = rand() % 3;
j = rand() % 3;
}while(matrix[i][j] != ' ');
if(i*j==9)
{
cout << "draw\n";
system("pause");
}
else
{
matrix[i][j] = 'O';
}
}
//Display the matrix
void disp_matrix()
{
int t;
for(t=0; t<3; t++) {
cout << matrix[t][0] << " | " << matrix[t][1] << " | " << matrix[t][2];
if(t != 2)
{
cout << "\n---|---|---\n";
}
}
cout << "\n";
}
//See if any winner
char check()
{
int i;
// New checking system
// check rows
for(i=0; i<3; i++)
if(matrix[i][0]==matrix[i][1] && matrix[i][0]==matrix[i][2])
{
return matrix[i][0];
}
// check columns
for(i=0; i<3; i++)
if(matrix[0][i]==matrix[1][i] && matrix[0][i]==matrix[2][i])
{
return matrix[0][i];
}
//Test diagonals for winner
if(matrix[0][0]==matrix[1][1] && matrix[1][1]==matrix[2][2])
{
return matrix[0][0];
}
if(matrix[0][2]==matrix[1][1] && matrix[1][1]==matrix[2][0])
{
return matrix[0][2];
}
/*
// Old checking system
// Check rows
if(matrix[0][0] == matrix[0][1] && matrix[0][0] == matrix[0][2])
{
return matrix[0][0];
}
if(matrix[1][0] == matrix[1][1] && matrix[1][0] == matrix[1][2])
{
return matrix[1][0];
}
if(matrix[2][0] == matrix[2][1] && matrix[2][0] == matrix[2][2])
{
return matrix[2][0];
}
// Check columns
if(matrix[0][0] == matrix[1][0] && matrix[0][0] == matrix[2][0])
{
return matrix[0][0];
}
if(matrix[0][1] == matrix[1][1] && matrix[0][1] == matrix[2][1])
{
return matrix[0][1];
}
if(matrix[0][2] == matrix[1][2] && matrix[0][2] == matrix[2][2])
{
return matrix[0][2];
}
// Check diagonal (left to right)
if(matrix[0][0]==matrix[1][1] && matrix[1][1]==matrix[2][2])
{
return matrix[0][0];
}
// Check diagonal (right to left)
if(matrix[0][2]==matrix[1][1] && matrix[1][1]==matrix[2][0])
{
return matrix[0][2];
}
*/
return ' ';
}
void f_matrix()
{
int t;
for(t=0; t<3; t++)
{
SaveFile << matrix[t][0] << matrix[t][1] << matrix[t][2] << "\n";
}
}
<marquee>Universal Project... Soon to be a .net</marquee>
|
|
|
|
|
Tic Tac Toe is now an "ASAP!!!' problem?
Oh dear, sounds like the homework assignment is nearly due.
-Blake
|
|
|
|
|