|
Thanks.I had a look at it before.But thats too heavy duty class for my app.
Maybe I will design a small dialog myself................
Cheers and ciao,
Sriram M R
|
|
|
|
|
You could install a hook on the message box and capture the WM_SETTEXT message for the child window (cancel button).
Jeremy L. Falcon
"The One Who Said, 'The One Who Said...'"
[My Latest Article]
Homepage: imputek.com
|
|
|
|
|
Use DialogBox to create a modal dialog box.
You can name the buttons whatever you like, and you
only need a few lines of code. For example:
// modal.cpp : Defines the entry point for the application.
#include "stdafx.h"
HINSTANCE hInst;
HWND hDlg;
LRESULT CALLBACK DialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
{
return TRUE;
}
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDOK:
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
case IDCANCEL:
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
}
break;
}
return FALSE;
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
DialogBox(hInst,(LPCTSTR)IDD_DIALOG1,hDlg,(DLGPROC)DialogProc);
return 0;
}
Of course you need to make a dialog box resource, but this
is easy with the visual editor in MS Visual C++
|
|
|
|
|
I'm trying to update the ofn.lpstrFile whenever CDN_TYPECHANGE is called from the OFNOTIFY.
Thanks
Tony
|
|
|
|
|
I've inserted a CDialog as a child of an MDI window with the following code:
m_pDlg = new CMyDlg(FromHandle(m_hWndMDIClient));
m_pDlg->Create(IDD_MYDIALOG, FromHandle(m_hWndMDIClient));
m_pDlg->SetFocus();
m_pDlg->ShowWindow(SW_SHOW);
This works fine however no matter what the title bar stays gray even while I'm actively working inside the dialog.
Any ideas?
-Jack
To an optimist the glass is half full.
To a pessimist the glass is half empty.
To a programmer the glass is twice as big as it needs to be.
|
|
|
|
|
Where do you declare your m_pDlg ?
Hung Son
A Vietnamese student
i-g.hypermart.net
dlhson2001@yahoo.com
|
|
|
|
|
In my MainFrame.h
-Jack
To an optimist the glass is half full.
To a pessimist the glass is half empty.
To a programmer the glass is twice as big as it needs to be.
|
|
|
|
|
I have variables (bools) as member variables in the MainFrame class that I use to keep track of which view is currently active and update menus and such accordingly.
The problem is I need to access one of the view-status variables in a worker thread to determine the correct action that should be taken (buffer data, or output data). I am currently trying to access the MainFrame member like this:
CMainFrame *pMF = (CMainFrame*)::AfxGetMainWnd();
bool bBufferData = pMF->m_bTempDepthCPSView;
However, its causing an access violation. I assume because the AfxGetMainWnd() function cannot return the proper pointer to MainFrame since it is called inside a global worker thread.
Does anyone have a suggestion to get around this??
Thanks
|
|
|
|
|
when you create your worker thread, you can pass an argument to it. So if the worker thread is invoked from your mainframe, you can pass "this" to it. And in your worker thread, do a type cast of the LOVOID pParam with (CMainFrame *)pParam.
|
|
|
|
|
Yes you got the hint. A worker thread does not have a window so AfxGetMainWnd will most likely return NULL. Even if you created a user interface thread and that one had a window AfxGetMainWnd will return a pointer to that window not the CMainFrame class.
Read this great article by Joseph M. Newcommer
Using Worker Threads
Best regards,
Alexandru Savescu
|
|
|
|
|
I have a program running on Win2k that uses the MSFlexGrid control on one its screens. When it comes time to render and communicate with this control the whole program crashes.
Does this mean the control is not registered? How would I register the control programmically or through installshield? If I'm way off on this one, anyone have any ideas what the problem might be?
Thanks!
"Why are we hiding from the police, Daddy?"
"We use VI, son. They use Emacs."
|
|
|
|
|
Hi
I want to write a thread which queries database and gets the data for each timespan say for each 3 minuts.I sreated one event for executing this functionality.Now how can I set that event to call that procedure for each time?
Please help me?
Thank you
Pathi
|
|
|
|
|
If your app is Windows-based (i.e. it has a message pump and all that) you can set a Windows timer and call SetEvent(hQueryEvent) in the handler. Check Nemanja Trifunovic's Timers tutorial for further info on Windows timers.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thank you Munoz
I did it but I want to know is there any other better option without using timer.Can I put WaitforMultipleObject()
method in while loop and call the procedure multipletimes?Then How can I break that loop?
Pathi
|
|
|
|
|
If you want it to wakeup every N minutes why don't you just put it to sleep().
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
I don't quite get what you're after, but maybe this approach is of some help: do it the other way around, omitting the "trigger" event and using just some cancelling event, like this:
switch(WaitForSingleObject(hCancelEvent,3000)){
case WAIT_OBJECT_0:
return 0;
break;
case WAIT_TIMEOUT:
break;
default:
...
break;
} Is this closer to what you're looking for?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi, everyone.
Sure, this is a dummy question, but I'm newbie with STL, so please, don't be angry.
The problem (or maybe feature) is in stl::map<int, myclass="">.insert(stl::map<int, myclass="">::value_type(int, myClassObj1)).
In this procedure I can see:
1. myClassObj2 is created by copy constructor from myClassObj1
2. myClassObj3 is created by copy constructor from myClassObj2
3. myClassObj2 is destroyed.
I guess, myClassObj2 is created in pair(const _T1& _V1, const _T2& _V2) and myClassObj3 is created in map::insert itself. I don't get it.
Could you please explain to me, why temporary object created? And is it possible to get rid of it?
Thank you in advance,
va'Lery
|
|
|
|
|
You need to pass it a pair.
e.g.
map<long, CString> mapNames;
mapNames.insert(make_pair(5, "Hello"))
Maps are a bit like Hashes, so the first value is the key, and the second is the value to be returned.
You may need to define a copy constructor for you class in the pair, depending on what it contains. e.g. pointers and the like.
hope this helps,
Giles
|
|
|
|
|
The temporary object myClassObj2 is created as part of the pair passed to map::insert , as you correctly guessed. This pair is used then internally to recreate the object to be inserted. Unfortunately, the value passed to map::insert cannot be used directly for two reasons:- What is passed is a
const reference, with which little can be done except replicate it. - The object actually inserted into the map is allocated by special means (namely resorting to an STL allocator), so the
pair you just passed simply does not fit. I hope this helped you understand the problem. In short, you can't get rid of the temporary object in any easy way. If it is very important not to do excessive copying you should go to some approach using ref-counted pointers or something like that.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
You can insert into a map using map[key] = value. Check out my STL article series, part D for an article on the workings of set and map.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
If I use map[key] = myClassObj1 then result is even more weird.
1. myClassObj2 is created by default constructor (constructor without arguments)
2. myClassObj3 is created by copy constructor from myClassObj2
3. myClassObj4 is created by copy constructor from myClassObj3
4. myClassObj3 is destroyed
5. myClassObj2 is destroyed
6. myClassObj4 call operator= myClassObj1
Hmmm... It's too much for me...
As Joaquín mentioned, there isn't simple way to prevent temporary object. But I have to, because I have collection of collections, so duplication of object will cost me too much. I think there is only one way to do it and it is creation of my own container.
Anyway, thanks a lot for all your answers, gents.
Life is good but it's better to live good.
|
|
|
|
|
think there is only one way to do it and it is creation of my own container.
I'd think twice before going into writing your home made container. Why not have containers of smart pointers to containers? Check Boost shared_ptr class template, which automagically gives you ref-counted access to dynamically allocated objects. The hassle of inserting this into your current code should be minimal.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
hi,
the subject says all, i have a TCHAR, and i need convert it to managed string, i am using string.Copy(), but it does not works.
Any body knows any way?
Thanks in Advance
Salamanca 2002 Capital Cultural Europea, Visitala
|
|
|
|
|
I didn't understand your question completely.
why don't you use CString in MFC.
Thanks
--Maya
|
|
|
|
|
He probably wants to use the string in a managed environment, like .NET.
Michel
If I am wrong or said something stupid, I apologize in advance
|
|
|
|