|
Hello,
I'm writing on a database application where the data is stored as HTML code (incl. images, JavaScripts and StyleSheets) in an SQlite database. The data is displayed in an MFC application with CHtmlView.
I can't use dynamic document writing via OnBeforeNavigate2 because I need my images and scripts to be stored in the database too. So I have written a very simple "Asynchronous Pluggable Protocol" for this. I need to register this handler (a DLL) globally with regsvr32.
But now I do not want to split my application logic into the exe and the DLL; instead, I want the whole application logic to reside in the MFC exe. Including the load procedure for a specific HTML page/images from the database.
So my idea is: In my app, I navigate with CHtmlView to myapp://<pageid>. Then my protocol handler is called. This DLL now requests the actual data from the running MFC application. The MFC app in turn loads the specific data from the SQLite database and passes the data back to the DLL.
The big question now is: What is the simplest method (IPC) to request data (up to a few MB) from a running application?
A great thing would be if the DLL could just call a defined function from the running exe like:
void getContent(int pageID, char *buffer, int *len);
or better:
void GetContent(char *url, char *buffer, int *len);
But I guess this is not easy. So I rely in IPC. But IPC is a very complex topic; I have no experience with it in Windows. Additionally, synchronization is a complicated issue too.
How would you solve this problem?
Is there a simple method that fits to my description?
WM_COPYDATA would be possible but unfortunately the Pluggable Protocol does not have a message queue. And I also need to pass the URL to the application when requesting a specified content.
Thank you for any hints!
Niki
|
|
|
|
|
How about using sockets or pipes?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
Hi,
The main problem is that I have no experience with these. But at first glance they seem to be too complicated.
I need no Networking support, it should just go fast & simple. Sockets are really oversized for that.
Problem with shared memory: I need complex caching structures and synchronization.
I would seek for an IPC method that works very simple like a remote-process function call and which is blocking: I request something in my MFC app and get the answer directly; the DLL should be blocking while this process is done.
I have experimented with WM_COPYDATA. But here I need to create a dummy window inside my DLL, send WM_COPYDATA to my MFC app to request the data and in turn send another WM_COPYDATA back to the DLL with the actual data. Too much complexity and oversize I also need to copy the data a few times.
Named Pipes: I do not know them exactly but is this really simple for my case? How do I manage the server part in my MFC app? Do I need a separate thread for this? Does this work when there are requests done simultanely?
Niki
|
|
|
|
|
Sure it can get complicated, but that's where you earn your money.
Don't wimp out!
|
|
|
|
|
I HAVE THE SOLUTION!!!
The DLL is loaded into the same address space of my application!!
So I can just use pointers in normal WM_USER messages and I do not need any IPC!!
And the best thing: I do not need synchronizing; this is done automatically: I just send a WM_USER with SendMessage to my view window which reads the data from the database and passes a pointer to that data to the DLL. The good thing: SendMessage is blocking while this is done so I do not need to lock my database variables with critical sections.
And if there is another request in parallel, it is spooled automatically by the windows messaging system and SendMessage is blocking again.
Please correct me if I am wrong.
Regards,
Niki
|
|
|
|
|
Hey everybody!
I'm trying to write a function that receives the iterator as a template, but I got really stuck with something I don't quite understand.
I wrote the function:
template<typename _iter_t="">
bool start_with( wstring& one, wstring& two );
</typename>
in the function I'm using one.begin() and one.end() (or two.begin()...) to get the iterators:
_iter_t me = one.begin();
BUT obviously it is not good, because I'm getting iterator, and if the _iter_t is "reverse_iterator", I'll get compilation error...
How do I get from "one" and "two" the right iterator (iterator or reverse_iterator) ???
Thanks!!!
|
|
|
|
|
I'd do it like this:
template <class iter_t>
bool starts_with(iter_t one_begin, iter_t one_end, iter_t two_begin, iter_t two_end)
There's no way to deduce the string method you need from the iterator type really.
Have a look at the way the Boost String Algorithm library[^] does that sort of function.
|
|
|
|
|
Well, I want to set an array of string name parts from a code isnide of a IF.
I cannot declare it in the start of the program becouse at that moment I do not know the number of itmes to set the array.
Merry Christmas
|
|
|
|
|
for instance
char ** g_pszString;
int g_iStringCount;
if (whatever)
{
g_iStringCount = 3;
g_pszString = new char * [g_iStringCount];
g_pszString[0] = "Hello";
g_pszString[1] = "World";
g_pszString[2] = "!";
}
delete [] g_pszString;
BTW using STL is a really more elegant in your scenario, for instance
#include <string>
#include <vector>
using namespace std;
vector <string> g_string;
if (whatever)
{
g_string.push_back(string("Hello"));
g_string.push_back(string("World"));
g_string.push_back(string("!"));
}
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks a lot, I have never worked with Vector, so It will be very interesting.
|
|
|
|
|
I want to get any process module no matter how the process launched by using CreateProcess or double clicking the *.exe file.
I know, EnumProcessModules mightbe can help me, but it will retrieve all modules(dlls included, so i will have to search what's i want), i only want to get the main module(the first instance parameter passed to WinMain entry).
Regards
|
|
|
|
|
|
In fact, i can get the process's identifier successfully. But, now, i want to get its menu use ::LoadMenu API. You you, the API need the instance of the .exe module. so, i'll have to retrieve the exe module.
And, follow your guide, i use GetModuleInformation to retrieve all the information successfully.
Thanks. All
modified on Sunday, December 28, 2008 9:51 PM
|
|
|
|
|
Is this[^] maybe what you are lookign for?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
i really want to retrieve module information of the exe, i meant the parameter transferred into WinMain.
Thanks for your reply
|
|
|
|
|
Ah, sorry, i thought you only needed the name of the executable.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
Do you need to Enum Processes with kernel and user times[^] of course David Crow has an article about enum processes on the codeproject,too.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
oh, sorry, i only want to get the main module of the process, not the executing time.
thanks for your reply
|
|
|
|
|
Hi, this is a question about understanding how Windows GUI internals work.
Can someone explain why overlapping controls are not supported... or what the technical limitations are. For example MSDN says in KB79981 that overlapping controls are not supported. I guess this refers only to siblings, because there should be no problems with overlapping controls when the overlapping controls are childs (e.g. a normal dialog and some controls).
What wonders me are group boxes, where the overlapping controls are on the same client-parent hierachy. The client area of a group box clearly overlaps with the enclosed controls (e.g. group box with edit boxes in a settings dialog). Are group boxes a special case?
Thanks for some help.
|
|
|
|
|
I would say group boxes are a special case, since they draw properly
even with overlapped controls.
Groupboxes are not actual controls - there isn't a groupbox control
in the Win32 control library. A groupbox is a special case of
a static control, and I would expect you won't see too many problems
overlapping controls on static controls since static controls don't
interact with the user.
As far as overlapping controls go, I'd worry more about this:
"Another consequence of having overlapping controls is that the
user of the application may be confused, because clicking the mouse
in the common area may not activate the control that the user intended
to activate."
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks for your feedback, Mark. I had a hard time figuring out how group boxes fit into these design limitations. The problems I have are not with user interactions (since there are none) but with redraw artefacts that occur sometimes, e.g. when moving another application window over my window.
Lessons learned: Do not overlap siblings or use WS_EX_TRANSPARENT, instead use client-parent hierarchies. Even HTML/DOM is more consistent and logical to use.
|
|
|
|
|
Moak wrote: Lessons learned: Do not overlap siblings or use WS_EX_TRANSPARENT
Yeah....transparent stuff I've found especially inconsistent with Win32
controls...one of the main reasons I've personally stopped using Win32/GDI/GDI+
for UI altogether.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
This is the Function declaration :
int MyClass::Send (MY_STRUCT *cStruct,
void *Para1, void *Para2,
void *Para3, void *Para4, void *Para5, void *Para6)
{
......
}
But when this function is executed ,why Para1...Para6 do not appear in the function?
MY_STRUCT Querries
Send(&Querries)
Thanks
|
|
|
|
|
what do you mean, "do not appear"?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
i mean why the number of parameters in the declaration and exectution is diffrent? any way, cause i don't understand why type for Para1, ...Para6 is void?
Thanks
|
|
|
|