|
Hi All,
I have a big problem..I want to open a new window link on the parent window instead of opening a new window..MSDN etc says do it like...
void Browser::OnNewWindow(BSTR URL, long Flags, BSTR TargetFrameName,
VARIANT* PostData, BSTR Headers, BOOL FAR* Cancel)
{
if (m_pBrowserApp) {
COleVariant varEmpty;
if (Cancel != NULL )
*Cancel = TRUE;
m_pBrowserApp->Navigate(URL, &varEmpty, &varEmpty, &varEmpty, &varEmpty);
}
}
but this thing is not working here..is there anything or anyone can help..I am in urgent need to do it..pls help...any help is highly appreciated..I have already posted it here in CP for 3 4 times already but there was no reponse...
Himanshu
|
|
|
|
|
Are you using MDI or SDI? If so, check out document-view articles.
Are you using CHTMLView?
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Hi All,
I have a big problem..I want to open a new window link on the parent window instead of opening a new window..MSDN etc says do it like...
void Browser::OnNewWindow(BSTR URL, long Flags, BSTR TargetFrameName,
VARIANT* PostData, BSTR Headers, BOOL FAR* Cancel)
{
if (m_pBrowserApp) {
COleVariant varEmpty;
if (Cancel != NULL )
*Cancel = TRUE;
m_pBrowserApp->Navigate(URL, &varEmpty, &varEmpty, &varEmpty, &varEmpty);
}
}
but this thing is not working here..is there anything or anyone can help..I am in urgent need to do it..pls help...any help is highly appreciated..I have already posted it here in CP for 3 4 times already but there was no reponse...
himanshu
|
|
|
|
|
I have this simple question about casting... take a look at the code snippet below:
Base * pBase;
Derived * pDerived;
pBase=new Base(1);
//DOWNCAST:
pDerived = dynamic_cast<derived*> (pBase); //Why did it NOT failed? Sure dynamic_cast supports "down-cast" but pBase is pointing to a "IN-complete" object.
//pDerived = (Derived*) pBase; //What's the difference between this sort of simple casting and dynamic_cast? I know that with simple casting, you can't down-cast. Does it mean that with up-cast, simple casting is just as good as dynamic_cast? I have a feeling that dynamic_cast will check at runtime if the object is complete/incomplete (simple casting don't do this) - and is thus safe. Is this the reason why we use dynamic_cast?
pDerived->m_nAge = 10; //Of course, this will crash.
Also, here's C4303 from MSDN:
"C-style cast from 'type1' to 'type2' is deprecated, use static_cast, __try_cast or dynamic_cast... C-style type casting or function-style casting is NOT SUPPORTED when using Managed Extensions for C++...."
>> I don't think it's NOT SUPPORTED - why the documentation states that it's not supported? I just did it in a C++ managed console application and it's just a warning - not error.
Thanks.
norm
|
|
|
|
|
|
norm wrote:
pDerived = dynamic_cast (pBase); //Why did it NOT failed? Sure dynamic_cast supports "down-cast" but pBase is pointing to a "IN-complete" object.
It did not fail because dynamic_cast doesn't fail, it returns NULL when there is a bad cast. Also, the correct way is:
pDerived = dynamic_cast <Dervied*> (pBase);
norm wrote:
I have a feeling that dynamic_cast will check at runtime if the object is complete/incomplete (simple casting don't do this) - and is thus safe
You are correct.
Best regards,
Alexandru Savescu
P.S. Interested in art? Visit this!
|
|
|
|
|
Alexandru Savescu wrote:
Also, the correct way is: ...
That's what he did IE just didn't display it because it treated the <Derived*> as a tag because he didn't use < and > . If you look at the page source, it's there
I thought the same thing initially
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
with all the different ways of doing it... dynamic_cast, __try_cast.. seems to be the way to go since they provide mechanism to confirm that cast is indeed a valid one.
But, why not just to this the good old C-style cast?
ClassB{...};
Class A : public ClassB
{
...
};
ClassA * pA = (ClassA*) new ClassB;
is the only reason why we don't do this no more is that C-style cast don't do run-time check?
norm
|
|
|
|
|
i'd like to have some documents about programming. i'm learning two subjects : "Artificial Intelligence" and "Graphics" in DOS in C and C++
please help me
thanks for your reading ;P
|
|
|
|
|
i'd like to have some documents about programming. i'm learning two subjects : "Artificial Intelligence" and "Graphics" in DOS in C and C++
please help me
thanks for your reading;P
|
|
|
|
|
I'm having trouble getting the following program to compile. I'm trying to write a program that will generate a random number (say our of 150 numbers for example). What am I doing wrong? My error message is 2601. I'm defining something wrong it appears.
<br />
#include <stdlib.h><br />
#include <iostream.h><br />
<br />
void main()<br />
{<br />
<br />
int nrand (int n)<br />
<br />
{<br />
<br />
int x = RAND_MAX / n;<br />
int r;<br />
<br />
do r = rand() / x;<br />
while (r >= n);<br />
cout<<r;<br />
return r;<br />
<br />
}<br />
}<br />
Thanks, Dave
"The man who reads nothing is better educated than the man who reads nothing but newspapers."- Thomas Jefferson
|
|
|
|
|
can you reformat the listing so it is easier to read ? (use the > < buttons below )
also, use srand to regenerate the random number generator (look in msnd for a full example)
Maximilien Lincourt
"Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
|
|
|
|
|
Some of the most immediate problems are your #includes aren't correct. Also (unless you have a custom stdlib.h) there is a typo - your first include should be stdlib, not cstdlib. the #includes should look like #include <stdlib.h> (actually, you probably had it correct, but because they look like HTML tags to the server processor, they got stripped). Also namespace is a C++ specific feature but in C++ you can't have locally defined functions (your int nrand(int n). You'll need to break out your nrand and call it from your main.
Create a NRand class and header file and save them in their own source files. #include the header in your main source file. Then you'll need to call the class with an integer. I didn't even look at the logic contained in your loop. Try to get a good compile and then check back in!
|
|
|
|
|
Look at my modification:
#include <cstdlib>
#include <iostream>
using namespace std;
int nrand (int n)
{
int x = RAND_MAX / n;
int r;
do r = rand() / x;
while (r >= n);
cout<<r;
return r;
}
void main()
{
}
Allan
|
|
|
|
|
Hint: if you have a space before and after the < > they get not deleted by the stupid HTML-interpreter at CP.
I did find a few things in your program.
First:
In your main() , you need to seed the random-generator, or you will get the same list of random numbers over and over. Use srand() for that. You can find an example how to do it in the MSDN.
Second:
You should do the cout in your main, after the call to your nrand -function. Separates the logic in natural parts: nrand() gets you a number, but does not say what to do with it, and main() uses the number to do whatever must be done, but does not bother how to generate it.
Third:
Your main sould be of return type int , and you do return 0; if all went well, otherwise something different (right now cant see why you would want to return anything other than 0.
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
Thanks all,
I will work with your suggestions.
Dave
"The man who reads nothing is better educated than the man who reads nothing but newspapers."- Thomas Jefferson
|
|
|
|
|
Hi, how can I implement a windows like IntelliSense which does not steal the focus of the activated windows. Could you help me. Thank you!
|
|
|
|
|
That would be a tool tip window. Create it with the WS_EX_TOOLWINDOW and WS_EX_TOPMOST extended styles, and the WS_POPUP style. Then to show the window, use SetWindowPos() inserting it after HWND_TOPMOST and using the SWP_NOACTIVATE and SWP_SHOWWINDOW flags.
WNDCLASS WndClass = {0};
WndClass.hInstance = hInstance;
WndClass.lpnfWndProc = ::DefWndProc;
WndClass.style = CS_SAVEBITS;
WndClass.hIcon = NULL;
WndClass.hbrBackGround = (HBRUSH)(COLOR_INFOBK + 1);
WndClass.lpszClassName = _T("MyToolTipClass");
::RegisterClass(&WndClass);
HWND ToolTip = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST,
_T("MyToolTipClass"),
_T(""),
WS_POPUP | WS_BORDER,
[EDIT] 0, 0, 0, 0, [/EDIT]
NULL,
NULL,
hInstance,
NULL);
SetWindowPos(ToolTip,
HWND_TOPMOST,
position.x,
position.y,
width,
height,
SWP_NOACTIVATE | SWP_SHOWWINDOW);
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
Thank you very much for your help! I will try it.
|
|
|
|
|
I am developing an MFC SDI program that needs to know what the screen res is because it needs a res of is 1024x768 or above to show its UI child windows properly. How would I get the size of the screen resolution that the user has set? Thanks.
bneacetp
|
|
|
|
|
You can use the GetDeviceCaps function retrieves device-specific information for the specified device. Visit the MSDN for its reference.
|
|
|
|
|
|
use..
DEVMODE devmode;
::EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devmode)
width =devmode.dmPelsWidth;
height =devmode.dmPelsHeight;
u r done with the screen resolution..
cheers
Himanshu
|
|
|
|
|
::GetSystemMetrics(SM_CXSCREEN)
::GetSystemMetrics(SM_CYSCREEN)
Gets the same values as GetDeviceCaps.
|
|
|
|
|
Hello,all
How control the size of a window meta file(WMF) when paste it into a richedit?
example:
//write a WMF and put it into the clipboard.
void copy()
{
CMetaFileDC * m_pMetaDC = new CMetaFileDC();
CRect rc(0,0,20000,20000);
m_pMetaDC->CreateEnhanced(GetDC(),_T ("c:\\test.wmf"),&rc,"name");
//drawing the lines in the DC.....
HENHMETAFILE hMF= m_pMetaDC->CloseEnhanced();
//copy to the clipboard
OpenClipboard();
EmptyClipboard();
::SetClipboardData(CF_ENHMETAFILE,hMF);
CloseClipboard();
}
//then paste the file in a CRichEditView.
void CMyView::PasteIt()
{
GetRichEditCtrl()->Paste();
//clear the clipboard
OpenClipboard();
EmptyClipboard();
CloseClipboard();
}
In windows2000, I can control the size of the metafile with the third parameter of the function CreateEnhanced().But in Win98, the parameter have no effect on the program. Why? How control the size in win98?
Thanks a lot.
Yes,Free Code project~~~~
|
|
|
|