|
mmm....
It is displayed 1 seconds before that the main window is displayed.
At that point of the execution I haven't used any pointer , I think.
Thanks anyway
Cheers,
Russell
|
|
|
|
|
You can use your debugger to narrow the problem. The call stack is also very usefull to find which of your function caused the crash.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
sigh: sigh:
It cames when
CvtkInteractor::Initialize()
Probally a bad dll of the VTK toolkit
Cheers,
Russell
|
|
|
|
|
I tried all what possible in VC++ , or windows to find device context
I want to start thread for engine simulation. but I have to pass the dc to my
function because it is generic class and not from mfc. what to do in this case.
or please let me know how to get view window from the generic class.
here is my code.
UINT CMy5CYLINDERView::ThreadFunc(LPVOID pParam)
{
CWnd *cwnd,*cwnd1;
cwnd1 = cwnd->GetWindow(1);
CDC* pDC = cwnd1->GetDC();
simulate* eng = (simulate*)pParam;
eng->nextpos(pDC); // program compiles on run gives access violation.
return 0;
}
void CMy5CYLINDERView::support()
{
FireCylinder();
for(int ii = 0;ii <= 3;ii++)
{
x[ii] = AfxBeginThread(ThreadFunc,(LPVOID)&engine[ii]);
}
}
|| ART OF LIVING ||
|
|
|
|
|
i think your problem is cwnd1 = cwnd->GetWindow(1); whats value cwnd(CWnd *cwnd)
whitesky
|
|
|
|
|
the reason why we are making a thread static because of to access the local resource of the class.
what u had done in the code is abosolutely wrong let me point out one of them
shivditya wrote: CWnd *cwnd,*cwnd1;
cwnd1 = cwnd->GetWindow(1);
In the above statement, cwnd* is not an initialized pointer. so u wont anything from there.
shivditya wrote: cwnd1 = cwnd->GetWindow(1);
This one something seems wrong. what u meant by GetWindow(1)?
it is better u pass this pointer the the function or make it accesseble trough some global static pointers.
i.e
static pszWindow; // declare as static member variable
static CMy5CYLINDERView::pszWindow = NULL; // initialize it globally
on Initial update, update this value with this pointer. then u can access it at the thread function
CMy5CYLINDERView::pszWindow->GetDC();
there is one more option.
define a structure that contains all information u need at thread
the definition may goes like this
typedef struct
{
CMy5CYLINDERView* pView;
Engine* pData;
}MyThreadParam;
now u "allocate memroy" (dont pass local variable) for the type of structure and fill with required informatio and pass to the thread param
at thread function type cast and use it.
SaRath
"D on't blindly follow rules you read somewhere without verifying that it makes sense for your situation!"
|
|
|
|
|
static CMy5CYLINDERView::pszWindow = NULL; // initialize it globally
on Initial update, update this value with this pointer. then u can access it at the thread function
CMy5CYLINDERView::pszWindow->GetDC();
there is one more option.
define a structure that contains all information u need at thread
the definition may goes like this
This highlighted line gives error as pszwindow is not object of CDC
its really problem beacause this thread function is static and it restricts a lot
|| ART OF LIVING ||
|
|
|
|
|
shivditya wrote: CWnd *cwnd,*cwnd1;
cwnd1 = cwnd->GetWindow(1);
CDC* pDC = cwnd1->GetDC();
You are using cwnd but it was never initialized....
The DC of which window do you want to get?
Is eng is part of that window?
If so , try using this code:
UINT CMy5CYLINDERView::ThreadFunc(LPVOID pParam)
{
YourWindow *wnd = (YourWindow *)pParam;
CDC* pDC = wnd->GetDC();
wnd->eng->nextpos(pDC);
return 0;
}
With best regards,
Eli
|
|
|
|
|
YourWindow *wnd = (YourWindow *)pParam;// You should pass the handle of the window as pParam
Here what means YourWindow
Beacuse I am able to get the active window I am not able to get device context.
will you please explain me what you mean by your window.
I tried long journey of HWND hwnd = :: GetActiveWindow()
then CDC tempdc = (CDC*)( ::GetWindowDC(hwnd));
but it also proved hopeless.
|| ART OF LIVING ||
|
|
|
|
|
Hi
I am popping a default mail client with an attachment for sending the mail in my application.I used a dll which inturn used Mapi.I could successfully popup the default mail client when Eudora,Outlook express are set as default mail clients but when i set MSOutLook 2003 as default i could not.
Any Suggestions or links would be useful for me.
Thanx
|
|
|
|
|
A CWnd based class creates a popup window:
BOOL b=CreateEx(0,0,0,WS_POPUP|CHILD,rc,pMum,100);
in XP, the call failed, by in 98 and other OS, the call is OK.
how to solve the problem for XP?
|
|
|
|
|
Can you be more specific do you get error
whitesky
|
|
|
|
|
|
BOOL o=CWnd::CreateEx(0, AfxRegisterWndClass(0), "CTest1", WS_POPUP, 0,0,0,0, NULL, 0);//return 1
whitesky
|
|
|
|
|
WS_POPUP and WS_CHILD flags do not go together. Only pass WS_POPUP with valid parent window handle.
GJ
|
|
|
|
|
|
Hi friends,
we try to use port forwarding concept in our application. freinds is their any software for port forwarding is available , so that we will use it in our application. or any sample code for port forwarding is available , so we will study that code and try to use in our application. If any links regarding port forwarding is ezists , provide us. frinds kindly give us reply.
regards
Girish
Software Developer
|
|
|
|
|
Port forwording is done by firewall automatically(u have to write rules).So what is ur purpose.
never say die
|
|
|
|
|
Hi,
I request u to kindly ans :
"How to place an edit box and dialog box on a window(SDI)( MFC based application)in VC++ dot Net-2003 version".
Thank you very much.
|
|
|
|
|
Change to Resource View, then change into the Dialog-Folder and edit the Dialog.
--
Contra vim mortem non est medicamen in hortem.
|
|
|
|
|
Hi
How can I get HWND from a process HANDLE?
|
|
|
|
|
Hadi Dayvary wrote: Hi
How can I get HWND from a process HANDLE?
You have to Enumerate all window on desktop and compare each Processs handle to that Enumerated Window Process Handle!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
So how to get process HANDLE from a HWND?
|
|
|
|
|
Hadi Dayvary wrote: So how to get process HANDLE from a HWND?
How about GetWindowThreadProcessId() ?
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
Use the following code
BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam)<br />
{<br />
EnumInfo info;<br />
DWORD pid;<br />
EnumWin * enumWin =<br />
reinterpret_cast(lParam);<br />
GetWindowThreadProcessId(hWnd, &pid);<br />
<br />
if (pid == enumWin->m_pid)<br />
{<br />
if(GetParent( hWnd ) == 0)<br />
{<br />
enumWin->m_found = TRUE;<br />
enumWin->m_hwnd = hWnd;<br />
AfxMessageBox("handle found!");<br />
return FALSE; <br />
}<br />
}<br />
return TRUE;
}
you can use WaitForInputIdle(...) for the process to finish initializing before you try to find its HWND. this will not work with apps that start with a process and switch to another while excuting (e.g. mozilla fire fox).
Appu..
"If you judge people, you have no time to love them."
|
|
|
|