|
i wrote a html control that is hosted in an html page (in an explorer bar). how do i get the address of the page that's hosted in that main internet explorer?
thanks
melinda
|
|
|
|
|
It would be helpful to show the route I've been taking:
CComPtr<idispatch> spDisp;
hr = m_spBrowser->get_Document( &spDisp );
CComPtr<ihtmldocument2> spDoc2;
hr = spDisp->QueryInterface( &spDoc2 );
CComPtr<ihtmlwindow2> spWindow;
hr = spDoc2->get_parentWindow( &spWindow );
spDoc2 = NULL;
spWindow->get_document( &spDoc2 );
CComBSTR bstrParentUrl;
spDoc2->get_URL( &bstrParentUrl );
In bstrParentUrl I get a bizarre value like "res//C:\DOCUMEN~1\...." I've tried many other approaches and either get an empty string or this value.
Thanks
Melinda.
|
|
|
|
|
OK, so I have this application with some modless dialogs here and there. I want to catch when the user presses Ctrl-Z, Ctrl+Y, etc. from whatever modeless dialog may be active. How can I accomplish this? Any suggestions?
[edit] I guess what I really want is to create a message handler for a keyboard shortcut. [/edit]
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Look up "Keyboard Accelerators" in MSDN. I don't know if it will help you, since you have all those dialog boxes, but it's a start.
Regards,
Alvaro
When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com
|
|
|
|
|
yea, that's what im playing with now.
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
A "global catcher" can be implemented only either in the Main message loop (MFC provides CWinApp::PreTranslateMessage for that), or, if you don#t have access to such a mechanism, by a windows hook.
(Hooks should be used only if absolutely necessary, though)
The Typical message loop looks like this:
while (GetMessage(&msg,...))
{
TranslateMessage(&msg);
DispatchMessage();
}
the MFC message loop looks (more or less) like this:
while (GetMessage())
{
if (!PreTranslateMessage(msg)) {
TranslataeMessage(&msg);
DispatchMessage(&msg);
}
}
You can implement a similar method if you're not using MFC.
Italian is a beautiful language. amare means to love, and amara bitter.
sighist | Agile Programming | doxygen
|
|
|
|
|
Another solution is TranslateAccelerator().
HACCEL hSomeAcc = ::LoadAccelerators(AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDR_SOME_ACCELERATOR));
PreTranslateMessage()
{
...
if(::TranslateAccelerator(m_hWnd, hSomeAcc, pMsg))
return(TRUE);
...
return FALSE;
}
Kuphryn
|
|
|
|
|
sweet! I was looking into this before I left for the day. I will try it tomorrow. Thanx!
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
I'm using the ping class listed in network/internet section of CP. When I compile my app in debug mode it works great. When I compile it in release mode I get the following error:
C:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afxcmn2.inl(293) : error C2084: function '__thiscall CIPAddressCtrl::CIPAddressCtrl(void)' already has a body
Both have the same settings. I'm not sure what this error means, can someone give some insight to this.
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
for some reason my application fails to start and gets
this message ...
Debug Assertion failed!
Program: blah blah blah
File: objcore.cpp
Line 43
When I rebuild all I see warnings C786: '...' : identifier was truncated to '255' characters in the debug information.
I really don't care about the debug information.
Why would debug information cause my application to fail?
Please help!
|
|
|
|
|
You've got bugs ...
(assuming it's a MFC application)
When the application crashes right at the beginning, it can be that one of the main resource ID or resource is corrupted or wrong. put a break point in InitInstance, or any other early called function and trace the problem.
Are you sure the warning is not C4786 ? if it is, then, it might be STL naming demangling ( with all the template stuff )
It's a level 1 warning, and can be left alone; or can be removed with
#pragma warning( disable : 4786 )
before including stl headers.
Max.
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
Diagnostic of the problem is incorrect.
If you run debug version (you do) and you use ASSERT in your code (you do) you will get the wonderful message.
Example:
ASSERT(nValue > 0); //if nValue <= 0 you will see dialog similar to the one you see.
Second item compilation warnings could be safely ignored
|
|
|
|
|
Thanks,
It looks like my assert is failing in the call to
SetRegistryKey?
I don't rememeber writting this part of the code?
How would my code cause this bug?
Thanks
|
|
|
|
|
That code is probably being called by other code which you are invoking. Look at the call stack to see who is calling who.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Hi,
want to use my own Polygon class called Polygon.
Defined in Polygon.h and Polygon.cpp.
Yet I get compiler errors because Visual C++ keeps
trying to use a pre-defeind Polygon class.
How can I make the compiler use my version of Polygon?
Do I hvae to rename my Polygon.h Polygon.cpp files to
something stupid like My_Polygon.h and My_Polygon.cpp
and change all the instances of Polygon to My_polygon
in those files?
I hope not!
|
|
|
|
|
that's why namespace was invented; to remove some of the name collisions.
put your class declaration and definition in a private namespace.
namespace MyNamespace
{
class Polygon
{
Polygon();
};
};
and in the definition use the fully qualified name.
MyNamespace::Polygon::Polygon()
{
}
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
Hello,
I'm an experienced programmer, but can't seem to find the info I need. I'd like to add a new option to the 'right-click' menu in internet explorer so rather than performing a 'save as' command I can send GIFs and JPEGs directly to an art program I've written. Is this possible? Perhaps this is a COM or OLE function?
thanks.
|
|
|
|
|
|
I'm using the DrawText API, and passing in DT_CALCRECT to query the size of the text.
It works well, but when the font it is italic, and I draw it into the rect returned, it gets cut off by a few pixels!
Below is VB sample code that shows the problem.
Has anyone else seen this? am i doing something wrong? Is this a bug?
Thanks!
- Alex
' Font:
Private Const LF_FACESIZE = 32
Private Type LOGFONT
lfHeight As Long
lfWidth As Long
lfEscapement As Long
lfOrientation As Long
lfWeight As Long
lfItalic As Byte
lfUnderline As Byte
lfStrikeOut As Byte
lfCharSet As Byte
lfOutPrecision As Byte
lfClipPrecision As Byte
lfQuality As Byte
lfPitchAndFamily As Byte
lfFaceName(LF_FACESIZE) As Byte
End Type
Private Const FW_NORMAL = 400
Private Const FW_BOLD = 700
Private Const FF_DONTCARE = 0
Private Const DEFAULT_QUALITY = 0
Private Const DEFAULT_PITCH = 0
Private Const DEFAULT_CHARSET = 1
Private Declare Function CreateFontIndirect Lib "gdi32" Alias "CreateFontIndirectA" (lpLogFont As LOGFONT) As Long
Private Declare Function MulDiv Lib "kernel32" (ByVal nNumber As Long, ByVal nNumerator As Long, ByVal nDenominator As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long
Private Const LOGPIXELSY = 90
' Testing the font:
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long
Private Const DT_CALCRECT = &H400
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function OffsetRect Lib "user32" (lpRect As RECT, ByVal x As Long, ByVal y As Long) As Long
Public Sub Test(ByVal hdc As Long, fntThis As StdFont)
Dim tLF As LOGFONT
Dim hFnt As Long
Dim hFntOld As Long
Dim tR As RECT
' Create a LOGFONT structure equivalent to the
' StdFont font:
pOLEFontToLogFont fntThis, hdc, tLF
' Convert the LOGFONT into a font handle:
hFnt = CreateFontIndirect(tLF)
' Test the font out:
hFntOld = SelectObject(hdc, hFnt)
DrawText hdc, "NIPIGON", -1, tR, DT_CALCRECT
OffsetRect tR, 32, 32
DrawText hdc, "NIPIGON", -1, tR, 0&
SelectObject hdc, hFntOld
' Always remember to delete the font when finished
' with it:
DeleteObject hFnt
End Sub
Private Sub pOLEFontToLogFont(fntThis As StdFont, ByVal hdc As Long, tLF As LOGFONT)
Dim sFont As String
Dim iChar As Integer
Dim b() As Byte
' Convert an OLE StdFont to a LOGFONT structure:
With tLF
sFont = fntThis.Name
b = StrConv(sFont, vbFromUnicode)
For iChar = 1 To Len(sFont)
.lfFaceName(iChar - 1) = b(iChar - 1)
Next iChar
' Based on the Win32SDK documentation:
.lfHeight = -MulDiv((fntThis.Size), (GetDeviceCaps(hdc, LOGPIXELSY)), 72)
.lfItalic = fntThis.Italic
If (fntThis.Bold) Then
.lfWeight = FW_BOLD
Else
.lfWeight = FW_NORMAL
End If
.lfUnderline = fntThis.Underline
.lfStrikeOut = fntThis.Strikethrough
.lfCharSet = fntThis.Charset
End With
End Sub
Private Sub Command1_Click()
Dim sFnt As New StdFont
sFnt.Name = "Copperplate Gothic Bold"
sFnt.Size = 48
sFnt.Bold = True
sFnt.Italic = True
Test Me.hdc, sFnt
End Sub
|
|
|
|
|
this is how I use CALCRECT:
RECT pos = {0,0,0,0};
long len = strlen(text);
::DrawText(TmpDC,text,len,&pos,DT_CALCRECT);
pos.right+=pos.bottom;
|
|
|
|
|
Thanks for the response Davide.. so I take it you've had the same problem? I came up with a similar solution:
GetTextMetrics i_lHDC, metrics
If metrics.tmItalic <> 0 Then
lActualWidth = lActualWidth + metrics.tmAveCharWidth
End If
Basically I increase the width of the rect by the average character width if it is italic.
|
|
|
|
|
Hi,
I want to be able to do something like this ...
<br />
MyView::MyView( int w, int h) <br />
{<br />
...<br />
pDoc->m_buffer = malloc ( w * h );<br />
for ( int i=0; i<w; i++ ) {<br />
for ( int j=0; j<h; j++ ) {<br />
p_Doc->m_buffer[i][j] = PI * some_random();<br />
}<br />
}<br />
...<br />
}<br />
... my question is how should I declare m_buffer in my MyDoc class?
I thought I would do this ...
<br />
class MyDoc : public CDocument<br />
{<br />
...<br />
public:<br />
double m_buffer[][];<br />
...<br />
}<br />
but that don't compile. Please help!
|
|
|
|
|
Anonymous wrote:
double m_buffer[][];
replace by double** m_buffer ?
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
After I have converted a project from VC++ 6 to VC++7 (Visual Studio .NET). I tried to rebuild the project. I received this error message:
Command line error D2016 : '/O2' and '/RTC1' command-line
options are incompatible
Is this common? I looked up D2016 from Help menu and found this:
Visual C++ Concepts: Building a C/C++ Program
Command-Line Error D2016
'option1' and 'option2' Command-line options are incompatible
The command-line options cannot be specified together.
Example
cl /Gw /NDxx program.c
In this example, the /Gw and /NDxx options are incompatible
because each has a different special-entry sequence.
Check the CL or FL environment variable for option
specifications
I don't have command line with syntax cl /.... in my source code. Please help.
-Elizabeth
Eilzabeth
|
|
|
|
|
menu Project->Properties
Configuration Properties->C/C++->Command Line
remove /RTC1
|
|
|
|