|
ok that clears that up.
You might consider using the hook for WM_CREATE as just an event. Meaning that upon the event you use the process enumeration methods and process API's like GetStarupInfo() etc. to build your list.
led mike
|
|
|
|
|
This syntax with all those brackets is scaring me....
Can someone please tell me what is going on?
for ( unsigned int j = 0; j < ms_numInstances; j++ )<br />
{<br />
( *( (Ball*)(ms_instances[j]) ) ).m_stateTimeInterval = timeInterval;<br />
}
Thank You!
|
|
|
|
|
Is casting whatever there is inside ms_instances array to a Ball object pointer, and then is refering to that object that is beign pointed, you can resume it like this:
Ball b;
b.m_stateTimeInterval = timeInterbal;
Obviously dont replace the code, is just for you to see the same in a more simpler way
Hope it helps
|
|
|
|
|
It could also be written as:
for (...)
{
Ball *pBall = ms_instances[j];
( *pBall ).m_stateTimeInterval = timeInterval;
pBall->m_stateTimeInterval = timeInterval;
}
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I would prefer this:
for ( unsigned int j = 0; j < ms_numInstances; j++ )
{
Ball * const ball = ms_instances[j];
ball->m_stateTimeInterval = timeInterval;
}
Now it seems much clearer, I think. The ms_instances array contains pointers to Ball objects. This loop initializes the m_stateTimeInterval field of all of Ball objects.
|
|
|
|
|
Viorel. wrote: The ms_instances array contains pointers to Ball objects
What happens when j = 0;
Ball * const ball = ms_instance[0];
Does this mean it has no pointers because ms_instance[0] ?
Do you need atleast j = 1 to create a pointer ........ like ms_instance[1] means 1 pointer
.... ms_instance[2] means array of two pointers......... so what does 0 mean?
ball->m_stateTimeInterval = timeInterval;
--------------------------------------------------------------------------------------------
So for each j value, there will be an array of pointers created?
|
|
|
|
|
Jay03 wrote: Ball * const ball = ms_instance[0];
Arrays in C/C++ are 0-based. This line will access the first element in the ms_instance array and cast it to a pointer-to-a-Ball.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
ms_instances is apparently an array of pointers to instances of some kind of object.
this code gets element 'j' (a pointer) out of the array, then casts that pointer to a pointer-to-a-Ball: "compiler, treat this pointer as if it was a pointer to a Ball, instead of a pointer to whatever it is actually pointing at. then it dereferences the pointer and sets the m_state* member variable of what we all hope is an actual Ball object.
|
|
|
|
|
It is nothing more than the equivalent of doing the following:
for (unsigned int j = 0; j < ms_numInstances; j++)
{
Ball* pBall = (Ball*)ms_instances[j];
pBall->m_stateTimeInterval = timeInterval;
}
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
I'm using the web browser active-x control in an MFC application to browse some web sites. If I need to click links within this site however, sometimes it opens up a new IE window. I need it to always open up within the same window. In other words always target _SELF.
I tried looking through MSDN and other sites, but everything is always so cryptic and the examples are scarce.
Write now I call Browser.Navigate(myURL,NULL,NULL,NULL,NULL); to open a site. The 2nd NULL is supposed to be for the target name. I have yet to see an example where these 4 NULL's are actually set to anything else.
Can anyone shed some light as to how to do what I am trying to do.
Thanks in advance!!
|
|
|
|
|
univega_r304 wrote: Write now I call Browser.Navigate(myURL,NULL,NULL,NULL,NULL); to open a site. The 2nd NULL is supposed to be for the target name.
So have you tried "_SELF" as the second parameter?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
If it were only that easy... That's the very first thing I did...
Here's what I got:
error C2664: 'CExplorer::Navigate' : cannot convert parameter 3 from 'const char [6]' to 'VARIANT *'
|
|
|
|
|
How about:
VARIANT vTarget;
vTarget.vt = VT_BYREF|VT_I1;
vTarget.pcVal = ("_SELF");
m_ctrlBrowser.Navigate(..., &vTarget, ...);
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Ok, that compiled. However my original problem still exists. When I navigate to the page and click a link within, it still opens a new IE window. Something tells me I have to intercept it with NewWindow2(), but when I tried setting up that event, nothing happened. I do have OnNavigateComplete and OnBeforeNavigate2 working, but when I tried adding OnNewWindow2 to the list of events, nothing happens when it spawns a new window.
Any other suggestions?? Much appreciated!
|
|
|
|
|
univega_r304 wrote: Something tells me I have to intercept it with NewWindow2(), but when I tried setting up that event, nothing happened.
I got notified with:
BEGIN_EVENTSINK_MAP(CMyDlg, CDialog)
ON_EVENT(CMyDlg, IDC_EXPLORER, 251 , OnNewWindow, VTS_DISPATCH VTS_PBOOL)
END_EVENTSINK_MAP()
void CMyDlg::OnNewWindow(LPDISPATCH pDisp, BOOL FAR* URL)
{
TRACE("New window opening\n");
}
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
OK, I got that to work too...
When I originally tried the event I used the number 254 vs 251 like you have. Being new to this, is there any documentation that shows how you came up with that number.
Anyhow, so now I added a line to your code:
void CMyDlg::OnNewWindow(LPDISPATCH pDisp, BOOL FAR* URL)
{
TRACE("New window no longer opening\n");
*URL = TRUE;
}
(that should probably have been named CANCEL but I stuck with what you had)
That no longer spawns a new IE window, but it's also preventing it from opening up at all *sigh*.
Now if I can only get the link to target my window I'll be set...
|
|
|
|
|
univega_r304 wrote: ...is there any documentation that shows how you came up with that number.
Look in afxhtml.h .
univega_r304 wrote: (that should probably have been named CANCEL but I stuck with what you had)
The old copy-and-paste bug is to blame!
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thanks
Just one more step and I'm done!
Obviously now that I can cancel it from spawning a new window, I need to still be able to open it within the same window. get_locationURL isn't going to work obviously since it can't establish the new URL yet. Do you know how to extract the URL from the link you click on so I can call it in a new Navigate() command?
|
|
|
|
|
univega_r304 wrote: Do you know how to extract the URL from the link you click on...
Wouldn't that be the BeforeNavigate2 event?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
If it is, I'm not able to get the URL the link is pointing to. It's probably something that would still be handled by NewWindow... My guess is there's a few more parameters available, one of which would contain the URL to the link. Then I could simply navigate to it after the *Cancel = TRUE; command is processed.
I've been looking at KB Article Q185538 which is basically ideal for this situation, but the sample is in VB. I'm sure it must be related somehow but I haven't got it to work yet.
|
|
|
|
|
univega_r304 wrote: If it is, I'm not able to get the URL the link is pointing to. It's probably something that would still be handled by NewWindow... My guess is there's a few more parameters available, one of which would contain the URL to the link.
Do you have:
BEGIN_EVENTSINK_MAP(CMyDlg, CDialog)
ON_EVENT(CMyDlg, IDC_EXPLORER, 250 , OnBeforeNavigate,
VTS_DISPATCH VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PVARIANT VTS_PBOOL)
END_EVENTSINK_MAP()
void CMyDlg::OnBeforeNavigate(LPDISPATCH pDisp, VARIANT *URL, VARIANT *Flags, VARIANT *Target,
VARIANT *PostData, VARIANT *Headers, BOOL *Cancel )
{
ASSERT(V_VT(URL) == VT_BSTR);
TRACE("Before navigating to %S\n", V_BSTR(URL));
}
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
If I put *Cancel = TRUE; in NewWindow to prevent it spawning a new window then BeforeNavigate never gets called. It works for anything that doesn't spawn, however. Any other ideas? I can't imagine why something like this would be so difficult. It'd make a useful article if we can get it working....
|
|
|
|
|
univega_r304 wrote: If I put *Cancel = TRUE; in NewWindow to prevent it spawning a new window then BeforeNavigate never gets called. It works for anything that doesn't spawn, however.
I would think that would be the case (i.e., BeforeNavigate() getting called) no matter what NewWindow() did to Cancel since BeforeNavigate() would not know about the new window.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Take a look at http://msdn.microsoft.com/workshop/browser/webbrowser/reference/ifaces/dwebbrowserevents2/newwindow3.asp
NewWindow3 may be the better way to go?
|
|
|
|
|
I have a toolbar that when it is floating I can resize ( manually ).
The toolbar contains a combobox, a couple of static (CStatic derived ) controls and some normal standard buttons.
something like drawn in lousy ascii art, where | is the gripper and - is a separator.
<code>|</code>combobox static1 static2 <code>-</code> button1 <code>-</code> button2 <code>-</code> button3 <code>-</code> button4
after I resize I get something like :
<code>|</code>combobox static1
static2 <code>-</code> button1 <code>-</code> button2 <code>-</code> button3 <code>-</code> button4
if I resize further ( including some blank space beforre static2):
<code>|</code>combobox static1
static2 <code>-</code>
button1 <code>-</code> button2 <code>-</code> button3 <code>-</code> button4
It seems that there is no "break" between the combobox and the static1 controls.
What is the mechanism that controls that breaks in the toolbar ? is it the separator ?
I'm not certain what to google for to get an explanation.
Thanks for the help.
Max.
|
|
|
|