|
Put the window handle of the parent modeless dialog into a member variable of the child modeless dialog's class.
When the child modeless dialog is closing, capture the events with handlers, such as WM_CLOSE, WM_DESTROY, etc. In those handler,s post a registered window message to the parent window that informs the parent the child is closing.
That should work VERY well.
|
|
|
|
|
Hi,Everyone:
i'm running a program as form-based, Doc/view struct. i create a thread in the initialization of the
program, and in thread, we use while(1) circulation.
it runs well usually, but we'll get unexpected error dialog, (and program shut down), this is following error
infomation:
"access violation at 0x00000000: read of address 0x00000000". Process Stopped.
Can any one of you give me some suggestions? Thanks!
________________________________________
Many nights we've prayed with no proof anyone could hear, we were moving moutains long before we knew we could!
Yet now i'm standing here, although we know there's much to fear, hope seemed like summer bird too swiftly flown away ...
There can be miracles! When you believe, though hope is frail, it's hard to kill!
Who knows what miracles, you can achieve! When you believe, somehow you will ...
YOU WILL WHEN YOU BELIEVE
|
|
|
|
|
In My CvcydcjDoc Class, i have such kind of memory to store data.
<br />
class CvcydcjDoc : public CDocument<br />
{<br />
protected:
CvcydcjDoc();<br />
DECLARE_DYNCREATE(CvcydcjDoc)<br />
<br />
public:<br />
struct MEM_MEMORY{<br />
int State;
<br />
char szBz[100];
int nCjzcs;
int nSbzcg;
int nZdcjcs;
char szZje[12];
int nCjcgcs;
int nZdcjcgcs;
int nCjymcs;
int nZdcjsbcs;
char szRowid[20];<br />
char szCjzt[2];
<br />
...<br />
<br />
};<br />
<br />
MEM_MEMORY memRead[2000];<br />
and in my thread, i access data using this way:
1. First i get the Doc pointer:
CMainFrame* pMainFrmWnd = (CMainFrame*)AfxGetMainWnd();<br />
ASSERT(pMainFrmWnd != NULL);<br />
CvcydcjView* pMyView = NULL;<br />
CWnd* pchildWnd = pMainFrmWnd->GetWindow(GW_CHILD);<br />
ASSERT(pchildWnd->GetSafeHwnd() != NULL);<br />
pMyView = (CvcydcjView*)pchildWnd;<br />
ASSERT(pMyView != NULL);<br />
CListCtrl* pList = (CListCtrl*)pMyView->getItem(IDC_LIST_DIAL);<br />
CListCtrl* pListMsg = (CListCtrl*)pMyView->getItem(IDC_LIST_MESSAGE);<br />
CStatic* pCjcount = (CStatic*)pMyView->getItem(IDC_CJCOUNT);<br />
CStatic* pCjymcount = (CStatic*)pMyView->getItem(IDC_CJYMCOUNT);<br />
CStatic* pCjcgcount = (CStatic*)pMyView->getItem(IDC_CJCGCOUNT);<br />
CStatic* pCjcscount = (CStatic*)pMyView->getItem(IDC_CJCSCOUNT); <br />
CvcydcjDoc* pMydoc = (CvcydcjDoc*)lp;<br />
then i manipulate that data in this way:
<br />
...<br />
strcpy(pMydoc->memRead[nRecNumber].szCjzjhm,str);<br />
...<br />
i don't know whether it's the problem or not...
Hope someone can help me,,, Thx!
________________________________________
Many nights we've prayed with no proof anyone could hear, we were moving moutains long before we knew we could!
Yet now i'm standing here, although we know there's much to fear, hope seemed like summer bird too swiftly flown away ...
There can be miracles! When you believe, though hope is frail, it's hard to kill!
Who knows what miracles, you can achieve! When you believe, somehow you will ...
YOU WILL WHEN YOU BELIEVE
|
|
|
|
|
This kind of error can occur when the instruction pointer (IP) gets confused when returning from a message handler. One way to fix this is to make sure all your custom message handlers are in the format LRESULT MyClass::OnMyMessage(WPARAM wp, LPARAM lp) . Make sure you declare both the WPARAM and the LPARAM on all you message handlers even if you think they are not needed. Also have them return LRESULTs not voids.
HTH
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Thanks,PJ Arends!
But in my program i didn't use message handlers (i planned to use once, but now i didn't use it. Maybe cos i remained the definition?? )
<br />
#define WM_OPENRECORD WM_USER + 100 //<br />
#define WM_STARTCALL WM_USER + 101 //<br />
and i found i made a stupid mistake:
<br />
while(1)<br />
{<br />
<br />
pRs = new CADORecordset(pAdoDb);<br />
<br />
while(DB_CONNECTED)<br />
{<br />
Dosomething();<br />
<br />
if(DB_problem)break;<br />
}<br />
}<br />
it seemed i forgot to "delete pRs"!
<br />
while(1)<br />
{<br />
<br />
pRs = new CADORecordset(pAdoDb);<br />
<br />
while(DB_CONNECTED)<br />
{<br />
Dosomething();<br />
<br />
if(DB_problem)break;<br />
}<br />
delete pRs;<br />
}<br />
maybe this cause the problem? i'm not sure, now i'm letting the program run and watch whether i get next error. (if i do get, i'll go to ask you again,hope you don't feel it's a trouble )
Thank you sooooooooo much! Have a good day!!
________________________________________
Many nights we've prayed with no proof anyone could hear, we were moving moutains long before we knew we could!
Yet now i'm standing here, although we know there's much to fear, hope seemed like summer bird too swiftly flown away ...
There can be miracles! When you believe, though hope is frail, it's hard to kill!
Who knows what miracles, you can achieve! When you believe, somehow you will ...
YOU WILL WHEN YOU BELIEVE
|
|
|
|
|
hi. im just new in using VC++/MFC. does anyone know how to read an existing text file then transfer it to a Word document. like i select a text file, then when i press a button, a new file, which is a Word document, is generated. thanks for any ideas..
*************************************************************
Every man has a right to be stupid. Others abuse the right.
*************************************************************
|
|
|
|
|
generally, a computer has three or more drivers c: d: e:...
question is: how to get the system driver in program.
The sea is so big and my boat is so small.
|
|
|
|
|
Can anyone guide me on how to go about programmatically powering down a Windows 98 system - I'm pretty confused about what sequence of functions should be used to achieve this. Any recomendadtions would be appreciated !
Doug
|
|
|
|
|
Lookup ExitWindowsEx in MSDN.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
I tried to use the sample code given in MSDN for shutting down the system using ExitWindowsEx(). (I've reproduced it below for reference):-
BOOL MySystemShutdown()
{
HANDLE hToken;
TOKEN_PRIVILEGES tkp;
// Get a token for this process.
if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
return( FALSE );
// Get the LUID for the shutdown privilege.
LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,
&tkp.Privileges[0].Luid);
tkp.PrivilegeCount = 1; // one privilege to set
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
// Get the shutdown privilege for this process.
AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
(PTOKEN_PRIVILEGES)NULL, 0);
if (GetLastError() != ERROR_SUCCESS)
return FALSE;
// Shut down the system and force all applications to close.
if (!ExitWindowsEx(EWX_SHUTDOWN | EWX_FORCE, 0))
return FALSE;
return TRUE;
}
It worked fine on my Win2000 Pro system but not on the Win98 machine (for which I actually need it !). It fails on the
OpenProcessToken() function and when I call GetLastError() in response, it returns a value of 120 ("The function is not
supported on this system")
How should I be using ExitWindowsEx on Win98 ?? (or is there a better way to do it ?)
Thanks for any help !
Doug
|
|
|
|
|
Windows 9x does not use privileges, just call ExitWindowsEx directly. You can use GetVersionEx to see if the program is running on 9x or NT.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Hi again !!
I have now just used ExitWindowsEx(), but the program just returns without causing the PC to power down - however, I can't get it to stop at a breakpoint beyong ExitWindowsEx(). I should say that this was the problem that I had before I made my original post asking for help !! I'm calling the function as follows:-
BOOL rc;
rc = ExitWindowsEx(EWX_POWEROFF | EWX_FORCE | EWX_LOGOFF, 0);
if (!rc)
{
dwError = GetLastError();
}
Hopefully someone can tell me what I'm doing wrong !!
Doug
|
|
|
|
|
From the MSDN article on ExitWindowsEx
Parameters
uFlags
[in] Specifies the type of shutdown. This parameter must include one of the following values. This leads me to believe that the EWX_* values you specified are supposed to be mutually exclusive.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Hi PJ,
AT LONG LAST, I've cracked it !! Despite the descriptions of the possible values for uiFlags, EWX_SHUTDOWN appears to do the trick !! For reference, the values are EWX_POWEROFF = 8, EWX_FORCE = 4, EWX_REBOOT = 2, EWX_SHUTDOWN = 1, EWX_LOGOFF = 0. These are clearly bit-orientated and one would therefore assume that they could/should be used in combination. (I really don't understand why the use of EWX_SHUTDOWN doesn't result in the message "The system may now be powered off" and why don't I need to use EWX_FORCE (or maybe I do ?) Anyway, thanks for staying with me through this "journey" !!
Doug
|
|
|
|
|
Hello
I am trying to use the built-in OSK (On-Screen Keyboard) that comes bundled with W2K and Win-XP. I need this inside a STATIC control in my dialog based app.
So, I use
ShellExecute(AfxGetMainWnd()->m_hWnd,_T("open"),_T("osk.exe"), NULL, NULL, SW_SHOWMINIMIZED );
And do a bit of gymnastics to resize it into the static, remove the menu and the caption through using the following:
CMenu* pMenu = cOsk->GetMenu();
if(pMenu) // We don't want the users to 'Play' with any of the functions
{ pMenu->DeleteMenu(3,MF_BYPOSITION);
pMenu->DeleteMenu(2,MF_BYPOSITION);
pMenu->DeleteMenu(1,MF_BYPOSITION);
pMenu->DeleteMenu(0,MF_BYPOSITION);
}
cOsk->ModifyStyle(WS_CAPTION | WS_THICKFRAME ,WS_POPUP, SWP_NOSIZE );
cOsk->DrawMenuBar();
It all works fine as intended, but the initial load of the OSK flickers at the default place on screen, and only after that gets moved through ha call to MoveWindow() to where I need it
If anyone has any idea on how to load the OSK in a “Silent” mode, so that I can do what I want and only then show it to the user – please tell..
Cheers
Alex
|
|
|
|
|
Would you please let me know some concepts ,algorithms or codes regarding to the translation from a regional language(i.e.,Bengali) to English.Its may be a part of transliteration also.Particularly, it is needy to identify proper nouns from a given sentence or statement.How would I implement this?I approached to search a database (say,some.mdb)having names of persons in ISCII format .But it may become time consuming!!
Let it be identified, then is it possible to translate without searching database?
Help me.......
|
|
|
|
|
How to make a disabled button enabled at runtime by pressing a certain button
|
|
|
|
|
Call the disabled button's EnableWindow(TRUE) when the trigger button is pressed.
If this doesn't work, you may have to add an Update handler for the disabled button. Let me know....
Bob Ciora
|
|
|
|
|
In the "certain" button's handler, enable the disabled button by calling EnableWindow() . For example:
void CMyDialog::OnCertainButton()
{
m_disabledButton.EnableWindow (TRUE);
}
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I have a struct
struct CoData {
float x;
float y;
};
// Adding position of mouse every left click
CArray<codata,codata> arrayPoint;
CoData strRawCoords, strOut;
CString m_list;
if((nFlags & MK_LBUTTON) == MK_LBUTTON) {
strRawCoords.x = point.x;
strRawCoords.y = point.y;
arrayPoint.Add(strRawCoords);
}
// Print out the coordinates when right click
if((nFlags & MK_RBUTTON) == MK_RBUTTON) {
for(int i=0;i<getupperbound();i++) {
="" strout="arrayPoint.GetAt(i);
" m_list.format("%f="" %f",strout.x,strout.y);
="" pdc-="">TextOut(0,0,m_list);
pDC->SetTextColor(RGB(0,0,0));
pDC->SelectObject(NormalPen);
}
}
Cant work.
|
|
|
|
|
Do you see any output at all?
Is all of this within your OnMouseMove function? If so, then the problem is one of scope.
arrayPoint is local to OnMouseMove . When OnMouseMove exits, the array is destroyed, since its a local variable of OnMouseMove . So every time the mouse moves and your OnMouseMove is called, it builds, then destroys, this array.
Try moving the array out of the function and make it a member variable of your window or dialog.
Hope this helps!
Bob Ciora
|
|
|
|
|
Hi thanks,
Can you give me some guides?
|
|
|
|
|
First off, did that fix the problem?
What sorts of guides are you looking for? This website is full of guides! For general VisualStudio programming, I find the MSDN Library[^] an invaluable source of information.
Bob Ciora
|
|
|
|
|
I understand but it tried to create member variable but the VC++ doesnt allow me to add CArray<mystruct,mystruct> type of variable. I need more detail solution. I am new to VC++ but have C b/ground. THanks.
|
|
|
|
|
Instead of making the CArray a member of the class, just move the declaration to just above your OnMouseMove function. This moves it outside the function and outside the class. Effectively, it becomes a global variable *shudder* but it should still put a temporary band-aid on the problem.
As for C++ in general, if you're a seasoned C programmer, see if you can find a book called "Moving From C To C++". I got this book about 10 years ago, and it's the only C++ book I've ever needed.
Bob Ciora
|
|
|
|
|