|
Hello All.
I'm a beginner programmer and try to make a simple web browser using C++/MFC. With the help of this site, I managed to started it. I'd like to do the control on VIEW menu (Text Size) to be changed same as in IE. I don't know how can I do it. I'd like to ask some help for the people out there. Please teach/tell me how can I start to do it.
Any help will be much appreciated.
Thanks and more power to this site.
With great power comes a great responsibility.
|
|
|
|
|
babyspidy wrote:
I'm a beginner programmer and try to make a simple web browser using C++/MFC.
So have you see the CHtmlView class?
babyspidy wrote:
I'd like to do the control on VIEW menu (Text Size) to be changed same as in IE.
I'm not exactly sure what this means?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Thanks for the reply.
I have seen the CHtmlView class but not quite familiar how it works.
For the View menu found in IE menubar, there's a Text Size option which you can select Largest, Large, Medium, Small, and Smallest for the user to increase/decrease the text size. I want to do this function in my project but I don't know how I will put a function on it.
In my ****View.cpp, I put
ON_COMMAND(IDR_VIEW_LARGEST, .....)
ON_COMMAND(IDR_VIEW_LARGE, .....)
ON_COMMAND(IDR_VIEW_MEDIUM, .....)
ON_COMMAND(IDR_VIEW_SMALL, .....)
ON_COMMAND(IDR_VIEW_SMALLEST, .....)
...
but I don't know how I will implement the function for it. I hope someone knows how to handle those commands..
Thanks again and best regards.
With great power comes a great responsibility
|
|
|
|
|
If you are using CHtmlView, to obtain the current setting, try this:
VARIANT var;
ExecWB(OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER, NULL, &var);
To set a given size, try this:
VARIANT var;
var.vt = VT_I4;
var.lVal = 1;
ExecWB(OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER, &var, NULL);
Hope that helps,
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Thanks for the quick response.
Where I will set the code above.
From MESSAGE_MAP, I made this:
ON_COMMAND(ID_VIEW_LARGEST, CHtmlView::OnViewLargest)
.
.
.
then, I made a function for that using the line you gave and it goes like this.
void CHtmlView::OnViewLargest()
{
/* Assuming the following is in a member function of
a class derived from CHtmlView
*/
VARIANT var;
var.vt = VT_I4;
var.lVal = 4; // 1 means small
ExecWB(OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER, &var, NULL);
}
and so on...
Is this correct?
Sorry for being an ignorant with this matter. I am really a beginner in VC++/MFC Programmer. I hope I can overcome this.
Thanks for your patience guys and for giving some time of yours with this matter. It really helps a lot to me.
With great power comes a great responsibility.
|
|
|
|
|
You are using a view class derived from CHtmlView, right? Then, assuming your class is named CYourView and derived from CHtmlView, the lines in red are what you'd need to add:
class CYourView : public CHtmlView
{
.
.
.
<code>afx_msg void OnViewLargest();</code>
.
.
.
DECLARE_MESSAGE_MAP()
};
BEGIN_MESSAGE_MAP(CYourView, CHtmlView)
<code>ON_COMMAND(ID_VIEW_LARGEST, OnViewLargest)</code>
.
.
.
END_MESSAGE_MAP()
.
.
.
<code>void CYourView::OnViewLargest()
{
VARIANT var;
var.vt = VT_I4;
var.lVal = 4;
ExecWB(OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER, &var, NULL);
}</code>
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Thank you very much Mr. Jose Lamas.
It works now for me.
One more thing, when I click the Small option from the View Menubar, Medium option remains checked. The checked option should be change to Small. The check always remain on Medium option, it never change to the selected Size option.
How can I do that?
Thanks again and I really appreciated your help a lot.
With great power comes a great responsibility.
-- modified at 22:05 Sunday 28th August, 2005
|
|
|
|
|
You need to add ON_UPDATE_COMMAND_UI entries with a handler for each of the options. In each handler, you can call SetRadio on the CCmdUI parameter you receive. The value for SetRadio is TRUE when the current selection (obtained as shown in previous posts) matches the value that correspond to the menu entry for which you are handling the update command message.
For example:
afx_msg void OnUpdateViewTextSize(CCmdUI* pCmdUI);
ON_UPDATE_COMMAND_UI(ID_VIEW_SMALLEST, OnUpdateViewTextSize)
ON_UPDATE_COMMAND_UI(ID_VIEW_SMALL, OnUpdateViewTextSize)
ON_UPDATE_COMMAND_UI(ID_VIEW_MEDIUM, OnUpdateViewTextSize)
ON_UPDATE_COMMAND_UI(ID_VIEW_LARGE, OnUpdateViewTextSize)
ON_UPDATE_COMMAND_UI(ID_VIEW_LARGEST, OnUpdateViewTextSize)
long GetTextSizeFromMenuID(UINT nId)
{
long lVal = 2;
switch (nId)
{
default:
ASSERT(FALSE);
break;
case ID_VIEW_SMALLEST:
lVal = 0;
break;
case ID_VIEW_SMALL:
lVal = 1;
break;
case ID_VIEW_MEDIUM:
lVal = 2;
break;
case ID_VIEW_LARGE:
lVal = 3;
break;
case ID_VIEW_LARGEST:
lVal = 4;
break;
}
return lVal;
}
void CYourView::OnUpdateViewTextSize(CCmdUI* pCmdUI)
{
long lSize = GetTextSizeFromMenuID(pCmdUI->m_nID);
VARIANT var;
ExecWB(OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER, NULL, &var);
pCmdUI->SetRadio(var.vt == VT_I4 && var.lVal == lSize);
}
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Thank you very much Mr. Jose Lamas Rios.
I made it now. It really helps me a lot. I can now continue my project. I really appreciated your help here.
By the way, I would like to ask, is there's a way of showing a html that is within the resources but its not declared in .rc. I have read some forum regarding on CHtmlView using LoadFromResource command but it is necessary that all html files in res should be declared in .rc file. And for using Navigate command, the path or directory of the html file is required. If I used the resource path, still it needs to be declared in .rc. Is it possible to view the html file that is not declared in .rc?
Thanks again and best regards. More power to you Mr. Jose Lamas Rios. You're the man! More blessings for you.
With great power comes a great responsibility.
|
|
|
|
|
Hi,
I am trying to put together a Video Clip organizer for all of my captured AVI file clips.
I need to be able to get it to play the clip so that I can see what it was in order to catalog it, so I went for the "simplest" method using MCIWndCreate() and MCIWndPlay() etc...
Unfortunately when I try this, I get a message; "Video not available: Cannot find 'vids:dvsd' decompressor."
But if I just click the clip in explorer, it plays OK in Windows Media Player (v10)....
I am using Visual Studio.net 2003 on WinXP Professional.
At the same time I am using some AVIFile functions within the program to access various stream information from the file; if this is relevant in any way.
Anyone have any idea why this is happenning, and how to fix it, or is there a better way to get the clip to play?
Thanks,
Bryan.
|
|
|
|
|
OK, I didn't have a dvds codec installed on my development machine.
Just installed a frre one and all is well now.
Bryan.
|
|
|
|
|
I am trying to call a Fortran dll in my c++ code.
The fortran bit is as follows:
<br />
subroutine swap(x,y,z)<br />
real , intent(inout) :: x<br />
real , intent(inout) :: y<br />
real , intent(out) :: z<br />
real :: t<br />
!<br />
!DEC$ATTRIBUTES dllexport :: swap<br />
!DEC$ATTRIBUTES DEFAULT, DECORATE, ALIAS: 'swap' :: swap<br />
!<br />
t=x<br />
x=y<br />
y=t<br />
z=1.23<br />
end subroutine swap<br />
<\code><br />
<br />
The C++ calling code is:<br />
<br />
<code><br />
#include <iostream><br />
using namespace std;<br />
extern "C" __declspec(dllimport)void swap(double &x, double &y,double &z);<br />
int main() <br />
{<br />
double x,y,z;<br />
x = 10;<br />
y = 999;<br />
swap(x,y,z);<br />
cout<<x<<"\t"<<y<<"\t"<<z<<endl;<br />
return="" 0;<br />
}<br />
<\code=""><br />
<br />
There are some problems however. x and y are not swapped but they do display their original values on the console. And z has not been assigned a value. I think it's a problem with the C++ bit but I could be wrong. The good thing is that it compiles and executes.<br />
I will eventually try and do this in C# but one step at a time ;)<br />
<br />
Kash
|
|
|
|
|
Kash wrote:
extern "C" __declspec(dllimport)void swap(double &x, double &y,double &z);
Does Fortran support references? What happens if you change this to:
extern "C" __declspec(dllimport)void swap(double *x, double *y,double *z);
...
swap(&x, &y, &z);
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
If that version of Fortran supports pointers, then it probably can support references indirectly. After all, under the hood, a reference is just a pointer without the dereferencing symantics.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Hello all,
Could anyone tell me how to obtain the index of the selected item from a CMenu control?
The reason I want it is so that I can call CMenu::GetMenuString(int index,...); My goal is really to obtain the text of the selection. If anyone knows an easier way, I'd be happy to learn it.
-----------------
Genaro
\\\|
_ _
@ @
_\\
--|
_/
|
|
|
|
|
As the menu selection chnages you receive WM_MENUSELECT messages. You can use this with the command ID to get what you need, unless you need it after the selection has completed and the menu been dismissed.
If you vote me down, my score will only get lower
|
|
|
|
|
The menu is actually a popup menu... View/Doc... can I still use this message?
-----------------
Genaro
\\\|
_ _
@ @
_\\
--|
_/
|
|
|
|
|
Yes, but you have to map it in the window that owns the menu (the HWND or CWnd parameter passed to TrackPopupMenu)
If you vote me down, my score will only get lower
|
|
|
|
|
Can't you infer the text from the handler function that will get called? In other words, if your menu had "Open", "Close", and "Delete" options, you'd have a handler function for each. In each function you'd know what the text was that got you to that point? Does that make sense, or am I way off?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
The menu is actually a popup menu for an xml generator/editor/validator that i am creating. when you right click on an element, it will popup the menu, which will be populated dynamically with and insert option for every possibly child element (uses a dtd file to determine this at the beginning). However, since this works for any DTD file, the insert event for any element will be handled by the same function. Therefore, I need to get the text, to know which element I will be adding.
I hope this is clear... let me know if it isn't.
-----------------
Genaro
\\\|
_ _
@ @
_\\
--|
_/
|
|
|
|
|
picazo wrote:
...when you right click on an element, it will popup the menu, which will be populated dynamically with and insert option for every possibly child element...Therefore, I need to get the text, to know which element I will be adding.
This part confuses me. The first part indicates that the text for the menu items will come from a DTD file. The second part indicates that you need to know which menu item was selected in order to get its text. Am I reading that correctly?
What happens currently when a menu item is selected?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Okay, so for a new xml tree, a dtd file is specified... parsed and validated. Structures containing the information for this tree are stored. Once this is done, a skeleton xml tree is generate, and when a user right clicks on a node, a menu pops up that displays options for that node; such as an insert option for any valid child element. When a user makes an insert selection from the menu, I need to know which selection he made so that I know which item to insert.
I guess I don't really need the text for the selection, but rather the index so that I can check my valid children list for the given node and insert correctly.
I figured out how to get the ID of the selected element... using the
m_SelMade = CMenu::TrackPopupMenu(TPM_LEFTALIGN | TPM_NONOTIFY | TPM_RETURNCMD, point.x, point.y, this);
Now all I need to do is make sure to give each of the insert options a unique ID.
Thanks for the help.
-----------------
Genaro
\\\|
_ _
@ @
_\\
--|
_/
|
|
|
|
|
picazo wrote:
...when a user right clicks on a node...
In what type of control does this node exist?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
picazo wrote:
Now all I need to do is make sure to give each of the insert options a unique ID.
if you are filling the menu dynamically, and I assume that you know all the possibilities that the menu can contain; for example, for node X, you will put item a, b and c, and for node Z, you will put item a, b and d, ... for all node type. so you can manually add unique command ID in your resource.h file for each possible item.
Once that is done, use the return value from TrackPopupMenu, it will give you the ID that was selected because you used TPM_RETURNCMD .
then you can switch on those values ( or use a callback ).
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
i have generally heard adding WS_CLIPCHILDREN to a parent window reduces flicker and i couldve sworn it has worked for me like that in the past
but im writing an MFC application, it has a main frame tab control, and in the tabbable area i have a splitter with scrollable dialog views in it.
weirdest thing is, if the mainframe has WS_CLIPCHILDREN the Tab control flickers like crazy on resizing (mostly grey while sizing)
but without it it barely flickers at all (still flickers some)
(also i changed the behavoir for OnSize to not make the splitter fill the whole frame area, cause i think this was causing flicker also because i would just immediately resize the splitter back into the tab controls display area)
similarly i noticed that if my CSplitterWnds are created with WS_CLIPCLILDREN then whenever any part of the frame is resized ALL the child panes have TERRIBLE flickering
but when i take WS_CLIPCHILDREN back off of the splitters i have very minimal flickering (just like on the main tab control)
i dont understand why having WS_CLIPCHILDREN on Frames and Splitters would cause so much more terrible flicking for their child windows
|
|
|
|
|