|
I'm not creating any dialog for property page..What i'm doing is that i am creating 3 pages (Property pages) and adding those pages in property sheet.
Also it's Non-MFC..
Here's my code for creating the sheet..
Should i start new thread??
HWND CreatePropSheet()
{
PROPSHEETPAGE psp[4];
PROPSHEETHEADER psh;
memset(psp, 0, sizeof(PROPSHEETPAGE) * 4);
memset(&psh, 0, sizeof(PROPSHEETHEADER));
psp[0].dwSize = sizeof(PROPSHEETPAGE);
psp[0].dwFlags = PSP_USETITLE;
psp[0].hInstance = NULL;
psp[0].pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_MEDIUM);
psp[0].pszIcon = NULL;
psp[0].pfnDlgProc = (DLGPROC)Page1DlgProc;
psp[0].pszTitle = TEXT("Job");
psp[1].dwSize = sizeof(PROPSHEETPAGE);
psp[1].dwFlags = PSP_USETITLE;
psp[1].hInstance = NULL;
psp[1].pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_MEDIUM2);
psp[1].pszIcon = NULL;
psp[1].pfnDlgProc = (DLGPROC)Page3DlgProc;
psp[1].pszTitle = TEXT("Schedule");
psp[2].dwSize = sizeof(PROPSHEETPAGE);
psp[2].dwFlags = PSP_USETITLE;
psp[2].hInstance = NULL;
psp[2].pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_MEDIUM3);
psp[2].pszIcon = NULL;
psp[2].pfnDlgProc = (DLGPROC)Page4DlgProc;
psp[2].pszTitle = TEXT("Scan Options");
psh.dwSize = sizeof(PROPSHEETHEADER);
psh.dwFlags = PSH_PROPSHEETPAGE |PSH_USECALLBACK | PSH_MODELESS;
psh.hwndParent = NULL;
psh.hInstance = g_hInst;
psh.pszIcon = NULL;
psh.pszCaption = "Automatic Virus Check";
psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
psh.nStartPage = 0;
psh.ppsp = (LPCPROPSHEETPAGE) &psp;
psh.pfnCallback = (PFNPROPSHEETCALLBACK)PSheetCallback;
return (HWND)PropertySheet(&psh);
}
Ash..
|
|
|
|
|
I set the "Center" Property for pages also. As there is property page dialog box for tabs(Pages)...
There is no dialog for Propertysheet..Creating programmatically..
Ash..
|
|
|
|
|
Ashish Chauhan wrote: Should i start new thread??
I said, in the "future". The reason why I asked you to create a new thread is, your query will get more visibility and more people may give you valuable inputs. This thread is kind of buried now and I'll try helping you out, but I may or may not be able to solve it. If I fail to solve your query, then start a new thread.
Now, please show me what you tried with SetWindwoPos().
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Please try this code and tell me if it worked:
HWND hPWnd = CreatePropSheet();
RECT rc;
GetWindowRect(hPWnd, &rc);
SetWindowPos(hPWnd, NULL,
((GetSystemMetrics(SM_CXSCREEN) - (rc.right - rc.left)) / 2),
((GetSystemMetrics(SM_CYSCREEN) - (rc.bottom - rc.top)) / 2),
0, 0, SWP_NOSIZE | SWP_NOACTIVATE);
[ADD] BTW, Thanks for painting my messages red by voting. I appreciate it. [/ADD]
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Yeah..Thanks Rajesh
This code works...
Initially i was doing something like that
g_hwndPropSheet = CreatePropSheet();
RECT rect;
GetWindowRect(g_hwndPropSheet, &rect);
int xL = LOWORD(dwSize) / 2 - (rect.right - rect.left) / 2;
int yT = HIWORD(dwSize) / 2 - (rect.bottom - rect.top) / 2;
SetWindowPos(g_hwndPropSheet, NULL, xL, yT, -1, -1,
SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
g_hwndPropSheet is type of HWND.
Thanks again..
Ash..
|
|
|
|
|
Ashish Chauhan wrote: DateTimePicker??
Why do you repeatedly say DateTimePicker ? It belongs to the .NET framework class library. I believe that we're talking about CDateTimeCtrl .
Ashish Chauhan wrote: GetSystemTime(&st);
What are you doing using GetSystemTime() ? This would get the computer's time and not the time that's being shown in your DateTimeControl() ! Please use the DateTime_SetSystemtime Macro to set the value into your control. Also, check the return value of this macro. It should return a non zero value if it didn't fail. Try that and let me know the result.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Hi All,
I Create some thread by using the function _beginthreadex.
I hold some handle to this thread
(ThreadHandle = (HANDLE) _beginthreadex(...))
And now i want to kill the running thread and i don't know how to do it.
thanks for any help...
|
|
|
|
|
Let the thread procedure function exit by itself.
Maxwell Chen
|
|
|
|
|
There's a few ways to do it.
The nice way:
Before starting the thread, create an event object (CreateEvent). Share this event handle with your thread, check it periodically -- and when it becomes signalled, have the thread exit itself. It's always best for the thread to exit gracefully.
HANDLE hEvent = CreateEvent();
_beginThreadEx( NULL, 0, YourThreadFunc, hEvent, 0, &ThreadID );
unsigned int __stdcall YourThreadFunc( LPVOID pData )
{
HANDLE hEvent = (HANDLE)pData;
while ( WaitForSingleObject(hEvent,0) != WAIT_OBJECT_0 )
{
DoSomething();
}
return 0;
}
SetEvent(hEvent);
The nasty way:
TerminateThread( threadHandle );
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<a href="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</a>
|
|
|
|
|
I cant in my code check for event ... but using TerminateThread look better option for now.
but I dont understand why dont use the TerminateThread ?
I rad about TerminateThread in MSDN - and they wrote "TerminateThread is a dangerous function that should only be used in the most extreme cases" - but i dont see any problem.
Can you explain ?
Thanks.
modified on Tuesday, March 11, 2008 3:31 AM
|
|
|
|
|
Because it is not a natural way to exit your thread. First, if you allocated some resources in your thread, there's no way you will be able to clean them if you are using TerminateThread.
Second, you have no control about what you are doing: you will terminate the thread whatever it was processing. It means you can terminate it in the middle of something important that will be left not terminated (e.g. if you communicate with an external device, you started to send some data to it and then brutally stop it, leaving the device in an unknown state).
It is far better to handle that yourself, using a flag for example: you check regularly if this flag is false, if that's the case, you exit nicely the thread function (the general idea is having a loop that checks for this flag).
|
|
|
|
|
Ok, now i see the problem
Thanks.
|
|
|
|
|
If this is your first jaunt into threading, you'll run into some problems. There's a whole bunch of things that you need to learn about in order to make threading work right.
But once you figure them out -- you'll LOVE threading!
The most important lesson is "Don't take shortcuts" -- a certain level of discipline is important when constructing a program that employs threads.
I think I've forgotten how to write an unthreaded program. What did we do before threading?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<a href="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</a>
|
|
|
|
|
Hi,
Can anybody please explain, How virtual destructor works under the hood?
What happens exactly with virtual table?
Thanks in advance.
|
|
|
|
|
I think:
The destructor goes into the vtable.
When the destructor is called -- the top-most constructor is called first, executed, then in turn, the each of the parent destructors are called. The order is the opposite of the order that the constructors are executed.
If you didn't do a virtual destructor, the parent destructors are hidden. I, personally, always use virtual destructors.
Just off the top of my head.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<a href="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</a>
|
|
|
|
|
Peter Weyzen wrote: When the destructor is called -- the top-most constructor is called first
typo ?
|
|
|
|
|
sure seems like one!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<a href="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</a>
|
|
|
|
|
I assume you mean "When the (virtual)destructor is called -- the top-most constructor destructor is called first". If so, why don't you edit.
|
|
|
|
|
then your reply wouldn't make any sense.... and we don't want that!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<a href="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</a>
|
|
|
|
|
|
I have the following error
Error 1 error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup MSVCRTD.lib
I also have the WinMain defined and the subsystem set to Windows
and even the callign convention is __stdcall
Please help me urgently.. I am in need
Thanx in advance
|
|
|
|
|
How does your WinMain prototype look like?
Maxwell Chen
|
|
|
|
|
Project properties ->
Linker ->
Advanced ->
Entry Point->
wWinMainCRTStartup
wWinMainCRTStartup ...if App is UNICODE
WinMainCRTStartup ... if App is not UNICODE
|
|
|
|
|
Iam having a MFC application, in which we have a worker theread.
Some operation is happens in worker thread.And we call this application for 10 times it works well.But when we call this application for 25th time it crashes at 25th time.
Let me know what will be the reasons behind this.
According to me one of the reasons is data type matching.But intially we resolved this problem for 10th time then it works well till. 24th time and at 25th time it crashes.
According to me there will be some other reaons behind this crashing.
Let me reasons how to rsolve this type of crashing.
lavatema
|
|
|
|
|
We're not psychics. You haven’t provided enough information. What is the type of crash? Can you provide the call stack of the crash? Can you post the relevant code?
Steve
|
|
|
|