|
Hi all,
I wanna when user hited one of columns in the list control, program select all rows below the column !
and how can i understand user hited which column in list control ?
How can i do that ?
(Excusme about my English)
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
|
Thanks for your helps
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
I have a MDI application where the child windows are formviews of a single document. I would like to force the closing of the open document before a new document can be created or another document can be opened. I would like the document closing to follow the normal MFC close document operation of checking to see if the file is dirty and prompting for the user to save. After the user has taken the necessary save steps, the user would be presented with the standard MFC File NEW or File OPEN screens.
So far my attempts to use OnCloseDocument to force the active document to close have led to Assertions when CWinApp::OnFileNew is finally called.
All suggestions appreciated.
|
|
|
|
|
I'm not sure what you did in OnCloseDocument, but from the description of the problem, it sounds like you need to do some work in OnFileNew and OnFileOpen.
Specifically check the dirty flag, save the existing document, close the windows etc.
Hole this helps,
Bill
|
|
|
|
|
I did not override OnCloseDocument. I was trying to call it from my OnFileNew and OnFileOpen handlers in the main application class. I was doing this by getting a pointer to the only document open then calling the base class CWinApp::OnFileNew(). I finally got something working this evening. It looks like this:
afx_msg void CMyApp::OnFileNew( )
{
POSITION docPos = myTemplate->GetFirstDocPosition();
if (docPos != NULL)
{
// This is necessary because I will send a message to myself to call
// this handler again.
if (!iWasJustHere)
{
// force the standard close document handler
AfxGetMainWnd()->SendMessage(WM_COMMAND, ID_FILE_CLOSE, 0);
iWasJustHere = TRUE;
// Send a message to call this handler again because if I fall
// through and execute my base class OnFileNew the close will
// not have completed and my window handler gets messed up.
AfxGetMainWnd()->SendMessage(WM_COMMAND, ID_FILE_NEW, 0);
}
else
{
// we tried to close the document but the user chose Cancel
// in the standard ask user if they want to safe changes dialog.
iWasJustHere = FALSE;
}
}
else
{
// At this point we have closed any open document and can create
// a new one.
iWasJustHere = FALSE;
CWinApp::OnFileNew();
}
}
You can repeat this process for OnFileOpen() by replacing CWinApp::OnFileNew with the appropriate base class handler. I don't think it is necessarily the best way to handle this problem. But it was the only way I could find that worked without having to override the standard dialogs.
Interested in hearing your thoughts on this approach....
|
|
|
|
|
Hi all!
does any one ever have problems with CTreeCtrl::GetSelectedItem() function? I try to use this function to obtain the handle to the selected node in my tree. However, this function keeps returning me a null handle or wrong handle. Please advise if you have anything to say
Any help is really appreciated.
Thank You
Vu
vucsuf
|
|
|
|
|
Please post tree initialization and mentioned function code.
Tree control could fail to create for example.
|
|
|
|
|
The function GetSelectedItem() is fine. The problem is how I used it. I called it in my OnClick event. This function does not work correctly with onClick event. IT does work fine with OnSelChanged event.
I still don't have a good explaination on this issue. Does anyone know?
Vu
vucsuf
|
|
|
|
|
Hi All!
I keep on getting the compiler error:
bla bla bla already defined in file.obj
bla bla bla being a variable or function in my header files, file.obj being the header object file it is in.
Please help - it is driving me insane!
Cheers,
James Bird
spider907@hotmail.com
|
|
|
|
|
A number of situations can cause this error. If you post some code it'll be easier to spot your particular problem.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquin is right that some code would help us solve your exact problem. However, this is mostly likely caused by one thing: global variables not properly defined/declared.
When using a global variable here's the general rule:
1. Define the variable in one (and only one) CPP file, like this:
int g_nWhatever = 0;
2. Declare it externally wherever you need to use it. This is typically done by putting it inside a header file, but it can also be placed at the top of a CPP file or even inside a function's body. Here's what it looks like:
extern int g_nWhatever;
Let me know if this helped.
Regards,
Alvaro
|
|
|
|
|
Ah - what I do is I declare it in one header file, eg:
LPTSTR szWindowName = "My Program"
and then when ever I want to use it, I just include the header file and use it like this:
SetWindowText(hWnd, szWindowName);
It this the wrong way to do it?
Also, I have spotted that there in the stdafx.h header file, all of the variables are declared within a
#if !defined(STDAFX...)
#define STDAFX
#include <windows.h>
#endif
Could this be relevant to my problem?
Thankyou,
James Bird - birdjames@bigfoot.com
|
|
|
|
|
OK, there's the problem, you're defining szWindowName in one header file, but then including that header file in multiple CPP files. The result: szWindowName ends up being defined in all those CPP files and your linker gets upset.
You have two options:
1. If szWindowName is never going to change, you can just make it constant:
const LPCTSTR szWindowName = "My Program";
If you do this, then I recommend changing the name to something like WINDOW_NAME to make it obvious it's constant.
2. If szWindowName will change, then you need to make it work like a global variable, which I explained in the previous post. Then I recommend calling it g_szWindowName to make it obvious that its global.
Regards,
Alvaro
|
|
|
|
|
I need some help with this one pleaseee
"write a windows program that looks like a digital clock".
two parts:
first part: to built a simple windows program that does nothing but start a framwork from running.
second part: the way i envisage a clock functioning is that its updating should be essentially a backround process. The calculation of the system's time should occure say every 5 seconds. Then you format a string that will contain an updated time value, post it off for display, and put your program thread back to sleep. That leaves the program able to let other internal threads run.
|
|
|
|
|
Seems like homework, so I well let you work out the details.
The best way to approach this problem is not with threads, which add innecesary complexity, but rather with windows timers (see SetTimer() ). These timers can perform the task for which you proposed a background thread, namely get a message posted to your main thread periodically.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
I got a request to make a program that seamlessly writes out some generic info on the background on a Windows 2000 (or higher) machine. (info is such as quote of the hour, fre RAM, incoming mails, current song in Winamp, whaterver info that can be summarized in short strings, you get the idea)
Well, such a program needs a few properties: Transparancy, Not able to be activated, not show up in the taskbar. More ofcourse, but for now these are the important ones.
Trancaparency is easely fixed, just a layered window WS_EX_LAYERED with a call to the SetLayeredWindowAttributes function and selecting a COLORREF color to be treated as transparent.
Also giving it the WS_EX_NOACTIVATE style unables the windows to be in the foreground. And making it not able to show up in the taskbar, well, a toolbar have that property, so giving it the
WS_EX_TOOLWINDOW style solves that problem.
Now the part that I cannot solve remains, how to make the border, and most importantly, the titlebar to dissapear? (no x-shutdown icon isn't a problem, just use the commandline and send a shutdown mesage or something)
But for it to fit nicely onto the desktop background I need to remove the titlebar and border. Anyone who knows ?
// Christoffer Sandberg , christoffer_sandberg@hotmail
|
|
|
|
|
Well, if you are using the dialog editor from vc++, just change the border style to 'none' using the dialog properties 'styles' tab.... or with c++ code, call the ModifyStyle(WS_OVERLAPPEDWINDOW, 0, SWP_FRAMECHANGED) of your window class, and you have a window without any frame!
----
Rui Lopes
|
|
|
|
|
Ahh, that is indeed a neat function, unfortenatly is is a member of the CWindow class (ATL) or the CWnd (MFC)(atleast what I was able to figure out). What I have is a standard Win32 program (none ATL, none MFC) application, so I use the RegisterClassEx and CreateWindowEx functions in the API to do my work, so all I have access to is the hInstance and hWnd of the program/window. Is there anyway to go from there and still being able to remove the the WS_OVERLAPPEDWINDOW style?
|
|
|
|
|
Well, the ModifyStyle is a straitforward function to implement.
Use this code instead of the ModifyWindow,
<br />
SetWindowLong(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE)&~WS_OVERLAPPEDWINDOW);<br />
<br />
::SetWindowPos(hWnd, NULL, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_FRAMECHANGED);<br />
But since you are using the CreateWindowEx, you can create the window without the WS_OVERLAPPEDWINDOW style, so there is no need for this code....
----
Rui Lopes
|
|
|
|
|
How does one pass the parent dialog box's handle to the contructor of a child dialog box that it creates?
I need to access the public methods of the parent dialog box from the child dialog box.
Thanks.
|
|
|
|
|
When you create the child dialog, pass the pointer of the parent dialog For example, call this from a parent dialog
void CParentDlg::SomeFunc()
{
CChildDlg dlg(this);
dlg.DoModal();
.
.
}
Now call GetParent() to access the parent dialog
CParentDlg* pParentWnd = (CParentDlg*)GetParent(); Now use pParentWnd to access the public functions from child dialog
Hope this helps
// Fazlul
Get RadVC today! Play RAD in VC++
http://www.capitolsoft.com
|
|
|
|
|
|
Hello, the codegurus around the world.;)
GetParent() is one way, but not so much technically.
So, pass the handle of parent of the constructor.
CChildDlg dlg (this);
dlg.DoModal();
And the constructor of CChildDlg;
ChildDlg::ChildDlg (CWnd* pWnd)
{
ASSERT(pWnd);
m_pParent = pWnd;
}
Good Luck!
Have a nice day!
-Masaaki Onishi-
|
|
|
|