|
MESSAGE_HANDLER(WM_MYMESSAGE, OnMyMessage )
and the function prototype is
// LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
|
|
|
|
|
|
Hi All,
My problem is about casting between these types.
the scenario is below.
getdocument -> getactiveelement ->
"it's a frame" I need a way of casting this IHTMLElement to IHTMLElement2 or to IHTMLWindow2
/*
IHTMLElement* pa_el;
...get_activeelement(&pa_el);
CComQIPtr<ihtmlelement2,&iid_ihtmlelement2> pa_el2(pa_el);
I have a dispatch here in pa_el2 but it seems as something is wrong because when I call doScroll, I get errors... if I cast to IHTMLWindow2... it simply returns NULL... (myframe == null)
CComQIPtr<ihtmlwindow2,&iid_ihtmlwindow2> myframe(pa_el);
How can I access to a frame object if I have it as an IHTMLElement?
Please Help...
|
|
|
|
|
If you need IHTMLElement2 just ask for it. IHTMLElment2 inherits from IHTMLElement
IHTMLElement2* pElement;
get_ActiveElement(&pElement);
|
|
|
|
|
I tried it already... but I get this error...
error C2664: 'get_activeElement' : cannot convert parameter 1 from 'struct IHTMLElement2 ** ' to 'struct IHTMLElement ** '
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
|
|
|
|
|
Gurus
I have been trying unsuccessfully to use CFileFind to search a directory for files, I have successfully used this in the past but currently have hit the proverbial brick wall. The following code
CFileFind find;
find.FindFile(m_strDir);
while (find.FindNextFile())
{
if (!find.IsDots() &&
!find.IsDirectory())
{
CString strMsg = find.GetFilePath();
strMsg += " found.";
AfxMessageBox(strMsg, MB_OK | MB_APPLMODAL | MB_ICONSTOP);
}
}
find.Close();
should return all files that aren't current directory (.), parent directory (..) or a directory. All I get returned is . and ..
Any idea what I have screwed up?
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
|
|
|
|
|
you need to call FindFile() first before you call FindNextFile()
i.e)
if ( ff.FindFile() )
{
while(ff.FindNextFile() )
{
do something
}
do something
this handles the last
file found case
}
|
|
|
|
|
If you have a look at the second line of code you will see that I have called FindFile(), I just didn't rap it up with an if statement.
Anyone else got any suggestions?
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
|
|
|
|
|
From MSDN Library:
Return Value
Nonzero if there are more files; zero if this is the last file,
and the previous call to either FindFile or FindNextFile returned nonzero.
Not if no file was available
|
|
|
|
|
Hello,
I created (_mkdir) a directory from application 1.
When I try to remove it (_rmdir) from application 2, I have an error (EACCES).
I only can remove it from process 2 after process 1 is closed.
I guess process 1 is holding a reference on the opened directories.
Is there any mean to "free" all references to directories from one application ?
Thanks in advance.
PS: 1- The directory I am trying to delete is empty and the current directory is
the parent directory.
2 - I tried _rmdir, DeleteDirectory, ShFileOperation
Where there is a WISH, there is a WILL.
|
|
|
|
|
My application consists of two components: front end gui-manager and the server.
I have a bug that causes the server to crash very infrequently every other day.
Naturally I would like to find the bug, but as interim solution I want to restart the
server when it crashes. The code to do this is simple but unfortunately every time
the server crashes I get the modal pop up boxes so until a user clicks ok on the box
the gui doesn't get a "server exited" event and therefore can't restart the server.
Is there any way to disable this modal box for the specific application? Or may be there
is another way around?
Thanks,
Gregory.
|
|
|
|
|
I want to restart the server when it crashes.
If your server is a service running on W2K, you have the config option doing exactly that. You can also use SetUnhandledExceptionFilter function to disable msgbox.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hi!
Maybe somebody could help me out by pointing out what's wrong with the following code:
#include <iostream.h>
class CResult
{
public:
static void SetFoo(int);
static int GetFoo();
private:
static int foo;
};
void CResult::SetFoo(int f)
{
foo = f;
}
int CResult::GetFoo()
{
return(foo);
}
int main(int argc, char* argv[])
{
CResult::SetFoo(17);
cout << CResult::GetFoo();
return(0);
}
At the linking stage of the compilation (VC++ 6.0) I get the following error:
Result.obj : error LNK2001: unresolved external symbol "private: static int CResult::foo" (?foo@CResult@@0HA)
Static___Win32_Debug/Static.exe : fatal error LNK1120: 1 unresolved externals
Since I'm far from experienced in C++/VC++ I can't figure out how to get the above sample to work. I've probably misunderstood how static members/methods work, so any help would be greatly appreciated.
Thanks,
Jimmy
|
|
|
|
|
To get rid of the compilation errors, add the following line after declaration of CResult:
static int CResult::foo = 0;
Making foo/GetFoo/SetFoo static is another story. You know that all instances of CResult will share one foo, right?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
oops, typing error: no need for another static. Just this:
int CResult::foo = 0;
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
That's it. Now it's compiling and working without a hitch.
Thanks a lot!
|
|
|
|
|
Hi!
I have a problem enumerating messages in the exe/dll. May be I was so lucky to fail on bug?
Here is what I do (m_IDs defined as CDWordArray):
BOOL CEventSource::Enumerate()
{
m_IDs.RemoveAll();
return (EnumResourceNames(m_hModule,RT_MESSAGETABLE,EnumIDsProc,(LONG)this));
}
BOOL CEventSource::EnumIDsProc(HMODULE hModule,LPCTSTR lpType, LPTSTR lpName, LONG par)
{
CEventSource * pMe;
pMe=(CEventSource *)par;
pMe->m_IDs.Add((DWORD)lpName);
return true;
}
Both functions return true, m_IDs contain the single element =1, doesn't matter, is there such event ID in the file, or not.
To check the whole structure, I've replaced RT_MESSAGETABLE with RT_DIALOG and received the full list of dialog's IDs. So something wrong with messagetable. But what ?
Any help will be greatly appreciated.
Thanks in advance.
Regards,
Gennady
|
|
|
|
|
All messages are stored in one RT_MESSAGETABLE. Have a look on MESSAGE_RESOURCE_DATA and friends.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I suspected something like this. But first, the description of RT_MESSAGETABLE constant (message-table ENTRY) confused me. Second, I cannot discover, how to get the pointer to MESSAGE_RESOURCE_DATA.
And last. If FormatMessage knows the resource structure, why EnumResourceNames doesn't ? If EnumResourceNames knows the structure of all other resources, why it doesn't recognize the message table. Why it is so peculiar.
I guess, you're not the MS representative, so you may interpret the last questions as rhetorical.
Thanks.
Regards,
Gennady
|
|
|
|
|
I cannot discover, how to get the pointer to MESSAGE_RESOURCE_DATA.
LoadResource, then LockResource.
If EnumResourceNames knows the structure of all other resources...
Not sure about that. EnumResourceNames knows about PE file structure and knows how to interpret the resource directory. Note that you can add your own resource formats to a PE file. They're just embedded in the image and are 'raw bytes'; only your app knows how to deal with them.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Thanks.
As I've understand:
FindResource
LoadResource
LockResource
Deal with MESSAGE_RESOURCE_DATA, _BLOCK and _ENTRY
I can't believe that nobody had done it for message table once and forever! Message table is standard and explotable enough to justify this effort.
Thanks once more.
Regards,
Gennady
|
|
|
|
|
Yeah, Find/Load/LockResource works for me with app-defined resource format. I don't think you'll have much trouble with message tables.
Cheers,
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
How can i get the word that has a mouse pointed over it?
(note : Any words that appear on screen, not only on the active window.)
|
|
|
|
|
Hello,
I need to debug an ActiveX Exe. This executable is launched from an NT Service when the service is started. I've got the source code for both executables but can't figure out how to debug them at the same time.
Can anybody help me?
Thanks in advance.
Matthias
|
|
|
|
|
Hmmm... you might try placing DebugBreak calls (or _asm int 3) in both modules. When these get hit, you'll be promted to debug the application.
I'm thinking you might end up with two copies of the debugger running, which could get a bit wonky, but might work.
Definitely safer to experiment with this stuff by starting the service manually rather than automatically - you can really mess up your session with this stuff if you're not careful!
There are other approaches - I'm not _exactly_ sure what you need/want.
|
|
|
|