|
One solution is to declare a pointer to the dialog box as one of view's private members.
Inside OnClose(), call DestroyWindow(). Inside PostNcDestroy(), call
CDialog::PostNcDestroy() and delete the object via "delete this." Post a message to the view class and set the pointer to NULL.
Kuphryn
|
|
|
|
|
Put the "delete this" into the PostNcDestroy handler of your dialog.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I might work if you put on WM_DESTROY. If you put in the destructor it will never be called at best, or called recursively on the deleted object(read undefined).
|
|
|
|
|
I am drawing some figures and storing these figures as bmp file. All of this drawing is
done on a window that is not shown to the user.
This is done by using
memDC.CreateCompatibleDC(NULL);
bitmap.CreateCompatibleBitmap(&memDC, 600,400);
Now this memDC is used for drawing diffrent figures.
as memDC.Rectangle(---);
I use diffrent color of Pens to draw figures.
It works fine in normal case but in mine case when diffrent colors of pens are selected
only black color is displayed for all figures.
Help me so that using
memDC i can create figures generated by diffrent color of pens.
I hope this has clarified you.
Thanks.
|
|
|
|
|
try using NULL as the DC for your CreateCompatibleBitmap. when you use the memDC, you'll always get black & white.
-c
When history comes, it always takes you by surprise.
|
|
|
|
|
I'm using directdraw, and I got a problem.
I'm making a pong game, and I don't know
how to change the color of the rectangels
that the game is going to be build at.
Without ddraw, I'm doing that:
HDC hdc;
HPEN hPen;
HBRUSH hBrush;
hPen = GetPen (PS_SOLID, NULL, RGB(0,255,0));
hBrush = GetSolidBrush (RGB(0,0,0));
PAINTSTRUCT ps;
BeginPaint (hdc, &ps);
Rectangle (hdc, 23,54,100,249);
EndPaint ();
(I don't think the code is totally correct)
And it works!
When using ddraw, I'm writing something like this:
HDC hdc;
lpDDSBack->GetDC (&hdc);
Rectangle (hdc, 23,54,100,249);
lpDDSBack->ReleaseDC (hdc);
lpDDSPrimary->Flip (0, DDFLIP_WAIT);
WHERE IN THE H*LL DOES I PUT THE COLORS????
please, help me!!!
My english is bad?
Who cares!
|
|
|
|
|
I am editing a customer's code. It has a dialog with some buttons on it. IDOK and IDCANCEL are not present. I would like to select one of the buttons to be activated like a single button click. After the button has been activated, I would like to move the default button to another button. The tab stop is selected on each button, but tab does not bring up a focus.
TIA
Steve
|
|
|
|
|
I'm not sure what you need exactly, but it seems like you want to set the focus on a button. For that, SetFocus() should do the trick.
If you still need help, please post some code or try explaining the problem again.
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
|
|
|
|
|
One solution is to set the current default button. Here is an example.
-----
DWORD style = m_BtnA.GetStyle();
// Make sure ButtonA is not already the default button
if ((style & BS_DEFPUSHBUTTON) != 1)
{
// Get style of ButtonB
style = m_BtnB.GetStyle();
// Remove default push button style
style &= ~BS_DEFPUSHBUTTON;
// Set the style of ButtonB
::SendMessage(m_BtnB.GetSafeHwnd(), BM_SETSTYLE, (WPARAM)style, (LPARAM)TRUE);
// Inform the dialog about the new default control ID
SendMessage(DM_SETDEFID, m_BtnA.GetDlgCtrlID());
// Get the style of ButtonA
style = m_BtnA.GetStyle();
// add the default push button style
style |= BS_DEFPUSHBUTTON;
// set the style
::SendMessage(m_BtnA.GetSafeHwnd(), BM_SETSTYLE, (WPARAM)style, (LPARAM)TRUE);
-----
Kuphryn
|
|
|
|
|
Thanks for the suggestions. They will be very helpful for the next part of what I want to do once I solve the main problem. Upon further examination, I find that this is an MDI problem.
The MDI child window is being opened. The buttons I want to access are in the child window.
Upon opening of the child, hitting TAB or ENTER has no effect. If I click the buttons with the mouse, I now have TAB and ENTER control thoughout.
I can trap keystrokes in MainFrame. So the Mainframe seems to have the focus for keyboard input.
The big question:
How, once I have made the Child window, can I place the default focus inside of that window so that keystrokes are sent to the child windows controls?
Steve Stiller
|
|
|
|
|
I want to write a program to delete the everyone group from a machine. I have no ideal of what header I should use, the name of the function, and the sentax please help
|
|
|
|
|
You can start by learning about the how security works under Windows. A great article to give you a good introduction can be found through MSDN at http://msdn.microsoft.com/library/en-us/dnsecure/html/msdn_secguts.asp?frame=true[^].
From there you will have a better understanding of some of the data structures and functions used in the security APIs, and how you can then use them to manipulate users, groups, DACLs and the like.
Once you finish reading the article, you will find on the left side a menu with an Option of "Security". Click that and go down to "Security General" and finally to "SDK Documentation" and take a look at all the functions you can take advantage of on the Windows platform.
Good luck!
- Dana
|
|
|
|
|
I want to write a simple windows program that lets me run a dos program with different buttons for different arguments. (I use visual C++, but I'm quite a newbie to windows programming).
1. user makes sure my (front-end) program is in the same directory as the dos program.
2. user specifies the arguments (the bits that come after the the program name ie: program_name.exe -h) (the -h)
3. user specifies a filename for the input/output files (ie: program_name.exe -h input_file.bmp output_file.tgo
Any help would be graciously appreciated.
Thanks.
|
|
|
|
|
Take a look at
CreateProcess, WinExec or good old system
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Thanks, I did a search for that lot and I found
In CSomeDlg.h<br />
static BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam);<br />
DWORD processPid;<br />
<br />
In CSomeDlg.cpp<br />
void CSomeDlg::startProcess()<br />
{<br />
BOOL bWorked;<br />
STARTUPINFO suInfo;<br />
PROCESS_INFORMATION procInfo;<br />
CString m_Process = "C:\\wherever\\process\\we\\want\\to\\start.exe";<br />
char *vip = "C:\\wherever\\process\\we\\want\\to\\start.exe whatever command line arguments here";<br />
<br />
memset (&suInfo, 0, sizeof(suInfo));<br />
suInfo.cb = sizeof(suInfo);<br />
<br />
bWorked = ::CreateProcess(m_Process,<br />
vip,
NULL,<br />
NULL,<br />
FALSE,<br />
NORMAL_PRIORITY_CLASS,<br />
NULL,<br />
NULL,<br />
&suInfo,<br />
&procInfo);<br />
<br />
<br />
<br />
if (procInfo.dwThreadId = NULL)<br />
{<br />
MessageBox("nope");<br />
}<br />
<br />
playerPid = procInfo.dwProcessId;<br />
}<br />
<br />
<br />
<br />
void CSomeDlg::killProcess()<br />
{<br />
HANDLE ps = OpenProcess( SYNCHRONIZE|PROCESS_TERMINATE, FALSE, processPid);<br />
<br />
EnumWindows(EnumWindowsProc, processPid);<br />
<br />
CloseHandle(ps) ;<br />
}<br />
<br />
BOOL CALLBACK CSomeDlg::EnumWindowsProc(HWND hwnd, LPARAM lParam)<br />
{<br />
DWORD wndPid;<br />
CString Title;<br />
<br />
GetWindowThreadProcessId(hwnd, &wndPid);<br />
<br />
CWnd::FromHandle( hwnd )->GetWindowText(Title);<br />
<br />
if ( wndPid == (DWORD)lParam && Title.GetLength() != 0)<br />
{<br />
::PostMessage(hwnd, WM_CLOSE, 0, 0);<br />
return false;<br />
}<br />
else<br />
{<br />
return true;<br />
}<br />
}<br />
<br />
but I'm quite a newbie can someone help me fill in the blanks (like what other headers I need to include and what to put in the main() or winmain() body).confused:
Anyone?
|
|
|
|
|
Well, I have always been a pipes kinda guy and would normally recommend you look at popen() as it is much easier than CreateProcess, and is alittle more portable. But since you asked to see it as CreateProcess() I would recommend you check out http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q190351&[^] for sample code on spawning console apps and grabbing the handles to do intelligent things to it (control input/output etc).
Of course... if you wanted to know how to do it quick and dirty with popen, consider something like:
#include <stdio.h>
#include <stdlib.h>
int main()
{
char psBuffer[256];
FILE *pFile;
if( (pFile = _popen( "program_name.exe", "-h" )) == NULL )
exit( 1 );
<BR><BR>
while( !feof( pFile ) )
{
if( fgets( psBuffer, 256, pFile ) != NULL )
printf( psBuffer );
}
printf( "Process returned %d\n", _pclose( pFile ) );
}
Or something like that. That code may not work virbatim as I am writing that off the cuff in a browser
Anyways, I hope that link will help you with the CreateProcess() way of doing things. I like popen() when getting down and dirty but I find myself using CreateProcess() more now adays because I can attach a Security Descriptor to the thing. Your milage may vary.
Good luck!
- Dana
|
|
|
|
|
Thank you very much Dana.
Also read up on CreateProcess but I think I'll try some (windows) newbie tutorials first.
Thanks again. _EGGMAN_
|
|
|
|
|
Good morning.
I never was a real C programmer, I went from Pascal to C++ ...
so, a small function design question :
I often see this kind of function where the output value is at the same time returned by the function and assigned to a output variable
char* DoSomething(double val, char *buff)
{
strcpy(buff, something);
return buff;
}
Any explanation ?
Max.
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
This give u the usage in another function call for example
AfxMessageBox ( _T(DoSomething ( dValues , acBuffer ) ) );
while conserving the value returned in acBuffer
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
How can I set the time of a CTime variable? I want to set the time, not the date.
Thanks a lot.
n
|
|
|
|
|
There is a constructor (from docs):
CTime(
int nYear,
int nMonth,
int nDay,
int nHour,
int nMin,
int nSec,
int nDST = –1 );
|
|
|
|
|
From MSDN:
CTime::GetCurrentTime
static CTime PASCAL GetCurrentTime( );
Remarks
Returns a CTime object that represents the current time.
Example
CTime t = CTime::GetCurrentTime();
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
A CTime object holds both a date and time (which is unfortunate because the name of the class suggests that it just a time value).
So, given a CTime object, how do you go about changing just the time portion? If that's your question, the (also unfortunate) answer is by reassignment. Here's an example:
CTime t = CTime::GetCurrentTime();
t = CTime(t.GetYear(), t.GetMonth(), t.GetDay(), 0, 0, 0);
Regards,
Alvaro
All you need in this life is ignorance and confidence, and then success is sure. -- Mark Twain
|
|
|
|
|
Alvaro,
Your solution is brilliant!
Thanks a lot.
N
|
|
|
|
|
Time is represented by a 32/64 bit number. The date is always part of the "time". If you don't care about the date, always use the current date, and just add the #seconds that represents the time of day.
|
|
|
|
|