|
does anyone know how to subclass all controls of a specific type in a window? what i mean is the window style just like corel draw 9. everything including the CFileDialog and the print dialogs has the same style - same buttons, edit boxes,etc (i dont believe they subclassed each control separately)
Live long and in prosper
johny74656@gmail.com
|
|
|
|
|
The subclassing of a window can occur per window instance or for the entire class, meaning for the entire process.
So, if you want to subclass all windows for a single dialog, you need to subclass each instance of a child control window separately. You replace the window procedure for the window's instance. -> SetWindowLong(hWnd, GWL_WNDPROC, ... );
If you want all child windows to be modified for the entire application, then you can subclass the window procedure globally by replacing the window class's window procedure with your own code. -> SetClassLongPtr(hWnd, GCLP_WNDPROC, ... );
|
|
|
|
|
hello,
can somebody tell me how to write code for graying/ungraying of menu items?I have written following code but its not working:
HWND hwnd;
EnableMenuItem(GetMenu(hwnd), ID_GRAPHDISPLAY_CHANNEL1, MF_DISABLED| MF_GRAYED );
It gives error that GetMenu() doesnt take one parameter.
why?
please guide
thanks
|
|
|
|
|
|
hello,
this is not working.What i want is that when i close my child modeless dialog box the grayed menu item should be enabled.So in OnClose handler i am writing code for enabling menu item.But its not working.I have created an object of class CMenu and using function EnableMenuItem() as follows
CMenu mymenu;
mymenu.EnableMenuItem(ID_MENU_CHANNEL1,MF_ENABLED);
this is not working
plz help
thanks
|
|
|
|
|
sayup wrote:
when i close my child modeless dialog box the grayed menu item
Which menu item ? From which menu ?
sayup wrote:
CMenu mymenu;
mymenu.EnableMenuItem(ID_MENU_CHANNEL1,MF_ENABLED);
Is this because your CMenu is a local variable that you destroy immediately after leaving the function in which you have created it ? Post more code, plz.
~RaGE();
|
|
|
|
|
You may have more luck taking over the UPDATE_COMMAND_UI function for that menu item. This is a pretty simple process, and doesn't require that the modeless child dialog know anything about the parent, or have to send some sort of signal to indicate that it's been hidden or unhidden. The UPDATE_COMMAND_UI handlers get fired whenever that menu item is about to be displayed.
I'm going to assume that you have a View menu with your various modeless sub-dialogs represented within this menu. In this case, I'm going to further assume that you have a command ID assigned for each dialog. For example, you may have IDC_VIEW_MYCHILD as the ID for the menu command to toggle show/hide some child dialog.
Using ClassWizard on the parent window/frame/etc., find the IDC_VIEW_MYCHILD command in the left hand pane. In the right hand pane, you'll then see entries for COMMAND and UPDATE_COMMAND_UI. Double-click the UPDATE_COMMAND_UI to create an Update handler for that menu item, and go edit that code.
Like I said, MFC will call the UPDATE handler for each menu item as it's getting ready to display the menu. This allows the user to customize each menu item separately via the UPDATE handler for that item.
In your case, using the codes above, you'd end up with a new function along the lines of CMyFrame::OnUpdateViewMychild . This function will receive a pointer to a CCmdUI object. CCmdUI has a lot of features, but for your purposes, you'd only need the Enable() method. If you have a pointer to the modeless dialog, then you can simply Enable or Disable the menu item based on the visibility status of the dialog, as such:
void CMyFrame::OnUpdateViewMychild(CCmdUI * pCmdUI)
{
pCmdUI->Enable(!m_pMyChild->IsWindowVisible());
}
This code will enable (ungray) the menu item if the window is not visible, or disable (gray) the menu item if the window IS visible.
By using the UPDATE_COMMAND_UI handlers, you don't have to have the modeless child do any kind of mucking about with the main application menus or anything like that. This keeps them independent, and is a lot cleaner. In addition, one simple line of code takes care of your problem.
Hope this helps (and I hope I didn't "assume" too much )
Bob Ciora
|
|
|
|
|
Hello All,
I am having a List control in my [B]Form View[/B]. I want to create it dynamically by calling "CreateEx". My problem is when I am creating it is creating in different location than where I placed in the form. The code ( VC++ 6.0 / Windows 2000) is given below
DWORD dwStyle = LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP;<br />
CRect rect;<br />
GetDlgItem (IDC_LIST1)->GetWindowRect(&rect);<br />
VERIFY(m_oTabList.CreateEx(WS_EX_CLIENTEDGE, _T("TestControl"), _T(""), dwStyle, rect, this, IDC_LIST1, NULL));
GetWindowRect returns values {104, 400, 27, 498}. The Control is placed much below the location where i created.
Then I tried to use GetClientRect instead of GetWindowRect. At this time the value returned {0, 292, 0, 467} This time it draws at the top of the client area.
How to get the control location with respect to client area?
Thanks in Advance
Ravi
|
|
|
|
|
Ravi Sankar S wrote:
How to get the control location with respect to client area?
Api [ScreenToClient ] Will help
"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
|
|
|
|
|
You have two options:
i) Use GetWindowRect (which gives you rect in terms of screen coordinates) and then convert it using ScreenToClient. Then add the offset that you want to have for your list control from the top-left of your dialog.
ii) Use GetClientRect (which will directly give you the rectangle of YOUR COMPLETE DIALOG). So you need to add some offset to the top-left point (which is (0,0) right now), and subtract some offset from the bottom-right point.
Ravi Sankar S wrote:
At this time the value returned {0, 292, 0, 467} This time it draws at the top of the client area.
So from your description, I think using the rect {10, 250, 10, 400} would perhaps suit your needs.
Regards,
Pravin.
|
|
|
|
|
COCreateInstance() call failed from MFC client when trying to call the
interface for ATL COM EXE(LOCAL SERVER)...Any solution or workaround
|
|
|
|
|
any chance to see a piece of code and/or an error message ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Look at my earlier cry for the same error ..
http://www.tech-archive.net/Archive/Data/microsoft.public.data.oledb/2004-03/0086.html
it was mainly due to usage of improper or outdated usage of some header files ...
Look at the parameters passed in cocreateinstance() function and check if all the params are present in your relevent headers
redindian
|
|
|
|
|
Hi,
First did you initialize the COM subsystem by using COInitializeEx()...
" Action without vision is only passing time,
Vision without action is merely day dreaming,
But vision with action can change the world "
- Words from Nelson Mandela
Thanks & Regards,
Gopalakrishnan
|
|
|
|
|
HI all
I have the following problem .
I have a COblist member declared as protected in a class
CObList m_DataList;
Now in the virtual destructor of the same class
the data is cleaned up like this...
while(!m_DataList.IsEmpty())
delete m_DataList.RemoveHead();
...here assume the m_DataList has N elements ...
deleting N-1 elements is not a problem ..but when the Nth element is Removed from the m_DataList then Assertion occurs ..saying
Invalid heap pointer !! . I could not understand this at all ..
When the destructor is able to delete all the elements except the last one what could be the problem ?
Why should I face assertion when the last element is deleted ?
Can someone help me pls ?
dharani
|
|
|
|
|
Did you add the same object to the array more than once? If so, it would harf on deleting the duplicate.
What type of classes are you adding to the array? Are they all the same class, or is the last one different than the rest, and if so, does it have a virtual destructor?
He is smart. He will make our Windows go.
|
|
|
|
|
Hi Jack
I will check this point .In fact the destructor of the class is virtual one ..I will update you tomorrow ... pls give me idea after i post a proper response ..
thanks
redindian
|
|
|
|
|
for Mr Toxcct
i dont know how to proceed it if
if(...)i.e after ur coding now what i write in my case.
------------------------------------------------------
for all members
till now i did not get any fuitefull response.
please help me more.
-----------------------------------------------------
;sdfsd
;sdfsd
;sfhsd
;nfs
;gfsfjgsf
;X Y index
12 34 2333
14 56 3334
12 56 7895
;sdkfskd
;sdhfkjd
45 34 3433
------------------------------------------------
in the above file the line started with SEMICOLON will be consider as comments i.e i have to read only the lines stating without SEMICOLON and all lines starting from SEMICOLON will show an error exception and read that line that start without SEMICOLON.
so how can i read the above format of file reading.
waiting for + response.
david
|
|
|
|
|
hey David,
i saw you post, there was no need to repost :
1) the 1st one did not disapear from the screen
2) you didn't even gave me the time to answer...
3) i receive a mail when you answer to me
(
ok, now, the tests in the if will almost depend on how the file is formated, and what you want to make upon ...
as i didn't well understand what does the file contain (and as it is your job to think on it ), i just provided a base of code which you can complete depending the file content :
CString strFile = "theFile.txt";
CString strLine;
std::ifstream SourceFile(strFile);
char buffer[50];
while (!SourceFile.eof() && ::PathFileExists(strFile)) {
SourceFile.getline(buffer, sizeof(buffer));
strLine = buffer;
if (!strLine.GetLength()) break;
if (strLine[0] == ';') break;
}
SourceFile.close();
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I know this has been answered at least twice in the past, yet you do not indicate what is not working, or what you do not like, about those suggestions.
CStdioFile file("", CFile::modeRead);
CString strLine;
int XLOC, YLOC, INDIX;
while (file.ReadString(strLine) != FALSE)
{
if (strLine[0] != ';')
sscanf(strLine, "%d %d %d", &XLOC, &YLOC, &INDIX);
} If this does not work for you, indicate what is not right rather than create a new thread asking the same question. Problems are much easier to solve/track this way.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
i didn't proposed such a line reading as i wasn't sure if every lines were formated the same way (x, y, indix)...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
i have a problem about overload operator =
this is my code
CStringList& CTESTADOView::operator =(CStr &str)
{
this->lst=str.list;
return(lst);
}
: error C2582: 'CStringList' : 'operator =' function is unavailable
can anyone tell me where the wrong??
thanks in advance~~~!
nothing
|
|
|
|
|
From the compiler message: There is something wrong with = overloaded operator of CStringList. This means that there is no overloaded operator = for CStringList hence you cannot assign one List to another like you did. You will have to use some alternative method to do this like copying all the elements of one list to the other in a loop.
e.g., something like:
for(int i=0; i<str.list.GetCount();i++)
{
this->list.AddTail(str.list.GetAt(i));
}
<Font size = 1 color = red>
Steve Mayfield: "Coding in VB is like riding a tricycle...once you figured out how to peddle, its really hard to fall off."
</i></Font>
<a href='http://www.codeproject.com/script/Articles/list_articles.asp?userid=163403'> My Articles</a>
|
|
|
|
|
to sum Aamir up, you dont call the same function that is define in the CStringList class... check the parameters, their types...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
How can I change the border of listctrl?
Can you suggest any useful link?
Tanks in advance!
|
|
|
|