|
I am trying to port a largish VC6 project to VC7/VC8 beta. Problem:
I have an .idl file with an interface definition using a PROPVARIANT structure (which is now defined in propidl.idl)
The resulting type library is imported in the client using an #import statement.
In VC7, the interface gets declared with a nnamespace_TLB::__tag_inner_PROPVARIANT type,which is not related to the PROPVARIANT coming from windows headers (which in turn breaks all my code)
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
I'm writing application to connect one client to multiple servers (to send the same data to several servers).
I now how to make server to manipulate with many clients, but no how to send data to many servers in the proper way.
So, Is there a way to connect and send data to multiple servers from one client.
Do you have any example to help me?
Thank you.
|
|
|
|
|
You could round-robin the connections from your client to each server in turn, or create multiple threads, each of which sends data to a single client.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hi,
I have this problem I can't find much information about. Suppose I have the following function:
void test(float arg[][3])
{
}
...
float ** vertices = Allocate2DArray(10,3);
test(vertices);
...
float vertices2[10][3];
test(vertices2);
So basically in the first case it can't convert ** to [][3]. What's the difference? How can I cast it? I can't change the function because the real one is already written that way.
Finally a question about freeing the memory. Suppose I have
BYTE * temp = new BYTE[TotalSize]
float ** result = (float **) temp;
..followed by a loop to assign result[i] = (float *) to a location in temp[i*cols*sizeof(float)];
Now if I type delete[] result. Will that delete all the memory I allocated? After all I allocated a BYTE[], but then just did a bunch of assignments.
Thanks.
|
|
|
|
|
Budric B. wrote:
What's the difference?
Even though they can sometimes be used interchangeably, pointers and arrays are not the same thing. One way to achieve what you want is like:
double (*vertices)[3] = (double (*)[3]) malloc(10 * sizeof(*vertices));
for (int x = 0; x < 10; x++)
{
for (int y = 0; y < 3; y++)
vertices[x][y] = 0.0;
}
test(vertices);
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
FIRST PART:
If test(float* in){...}
vertices2 // is a pointer
test(vertices2) // ok
test(&vertices2) // error
vertices // is a pointer to a pointer
test(*vertices) // ok
test(vertices) // error
In this case a pointer to array of pointers, it gets a bit confusing.
float* pr = vertices[r];
float f = pr[c];
Therefore,
float f = (vertices[r])[c];
SECOND PART:
(*result)[i] == temp[i]
result[i] == &temp[i]
No the == are not typos.
I hope that helps.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
So, what is the difference between ** and [x][y]? Well, one is a static memory location and the other are pointers.
float **x;
float y[10][3];
x is a pointer to a pointer. So, what the compiler does it it goes to the address of the variable X. It then reads this address and then goes to the address stored at that location. It then uses this address as the place to store the float!
If you understand single pointers you can see how the double pointer works:
First Address = *x;
Second Address = *First Address;
The Actual Float Value = *Second Address;
At any level you can actually allocate a "block" of pointers that you can index into at that time.
So what's the difference with an array?
y[1][2] = 12;
Is actually
y[3 + 2] = 12;
It's a single block of memory! There are no pointers! In the case of even a single float *, the address of the variable stores the address that then stores the actual value! In the case of an array, the address of the variable stores the actual value!
So, a multi-dimentional pointer is actually a single block of memory that is then index by the compiler as one block. So if you have: rows by columns:
float x[row][column]
each row is maxcolumns size. So if you want to go to rowx, coly, you could simply do rowx*maxcolumns + coly. This would index that block of memory.
The compiler knows how to generate the correct code if it's an array or pointer. Remember, an array's address stores the actual data. The pointer's address, stores another address. That address then stores the data (in a single indirection case).
8bc7c0ec02c0e404c0cc0680f7018827ebee
|
|
|
|
|
Hey. I'm new to MFC. Here's the situation... I've got a DLL that's using shared MFC. I just want a my dialog to appear when a method in the DLL is called.
I've declared
AFX_MANAGE_STATE(AfxGetStaticModuleState());
in the method. The dialog has a class Dialog that extends CDHtmlDialog. In the method I have
Dialog dlg;<br />
dlg.DoModal();
What else is needed to make it appear? Does there need to be an object extending CWinApp, or can I just use the dialog by itself? If there has to be a CWinApp, do I need to declare it in the method or global in the DLL (I've tried both ways and neither works.)?
Many thanks for any help.
|
|
|
|
|
You need to start your project as a "regular DLL", not as "extension DLL". Then you can, simly spoken, work as it would be a normal Application. It has a CWinApp derived application object and you can use it with any kind of application.
An extension Dll does not have a CWinApp derived object. It uses the one from the client application, which leads to soms restraints.
Serch MSDN for more information, my english is too poor to explain it better.
MS
|
|
|
|
|
It is a regular DLL. What I'm wondering is if I NEED the CWinApp object at all. Can I not just do something like
Dialog dlg;<br />
dlg.DoModal();
and have that dialog appear? I've also tried making the dialog appear when InitInstance() is called in a globally declared CWinApp.
Dialog dlg;<br />
m_pMainWnd = &dlg;<br />
int result = dlg.DoModal();<br />
This doesn't make the dialog appear either. This works in an MFC application I've made, but when the same code is used in the DLL it doesn't work.
Thanks.
|
|
|
|
|
1) You need a CWinApp derived object because it provides the main message pump, the idle loop, and so on.
2) If "Dialog" in your example is a CDialog derived class (with dialog resource assigned) it should work.
MS
|
|
|
|
|
hi, i am new in MFC so i would need detail explaination and preferbly some codes
here is the application initialization
CAsevApp theApp;<br />
<br />
BOOL CAsevApp::InitInstance()<br />
{<br />
RECT rec;<br />
rec.bottom=100;<br />
rec.left = 100;<br />
rec.right = 100;<br />
rec.top = 100;<br />
<br />
main_window *m_pMainWnd = new main_window;<br />
m_pMainWnd->Create(<br />
"myWindowClass",<br />
"title",<br />
WS_OVERLAPPEDWINDOW,<br />
rec, CWnd::GetDesktopWindow(),0,0);<br />
return TRUE;
main_window is a derived class from CWnd, no extra stuff has been added
here i am trying to create a simple window with the "create" command
or more specifically, CWnd::Create command
what happens is that the program terminates immediately
i was expecting an empty movable/resizable window with the titlebar "title" to appear and stay there
is there something i did wrong?
please assist
|
|
|
|
|
Any reason why you are doing it this (hard) way rather than having AppWizard create an SDI/MDI application for you sans Doc/View support?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
You need a modal loop to prevent the app from exiting!
The code you are using creates a window and then exits the main routine.
If you really want to create the window like this you have to call m_pMainWnd->RunModalLoop() after creating the window.
Don't try it, just do it!
|
|
|
|
|
awah wrote:
is there something i did wrong?
Yeap, there is no Message Loop for that Window Running!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hi,
I have a window that has a some drawing in it and I have this child window that I would use to display information where the mouse is on the drawing.
How do I capture mouse movement in the chart window even when the mouse moves over the child window ?
I added a handler for WM_MOUSEMOVE to the chart window but when I pass over the child window I don't receive any WM_MOUSEMOVE messages, just when I am over the chart window. I need to get messages also when I am over that child window.
I know I could use GetCapture(), but I don't want to click the chart to initiate a GetCapture(), so if I use GetCapture() on that chart window, what would be the best way to know when to call release capture, in other words how do i know, for certain, that the mouse has left the chart window ?
thanks,
Louis.
|
|
|
|
|
From MSDN:
CWnd::SetCapture
Causes all subsequent mouse input to be sent to the current CWnd object regardless of the position of the cursor.
When CWnd no longer requires all mouse input, the application should call theReleaseCapture function so that other windows can receive mouse input.
I think that is what you want to do.
MS
|
|
|
|
|
Ok, I tried the SetCapture() and it works fine but I have a problem with the child window that I use to display information. This child window is moveable, but when SetCapture() is called for the chart window I cannot move the child window anymore (not receiving any messages)...I guess I could check with a hit test if the cursor is on the title bar of the child window...but this seems to be becoming a lot of work...is there another way ?
thanks for your help I am half way there.
Louis
|
|
|
|
|
You should also be able to trap these messages with PreTranslateMessge.
You need to add the handler for PreTranslateMessage (class wizzard). There you can "look" at the mouse messages and see for which window they are. Don' forget to pass them on to their destination.
MS
|
|
|
|
|
Good idea.
I added the handler seems to be working but again when mouse is in child window I dont receive messages. I don't get it, this child (chart info window) is just a child like the chart control.
Here's exactly what I have and did:
- A dialog that I use for a graph window.
- This dialog contains controls and one of those controls is a CStatic derived class that act as a chart control. There is nothing special about the control in how it handles messages except for drawing.
- At runtime I create a new dialog that is child of this dialog. This child dialog is the chart info window. To me it should be the same as another control in the dialog. It does nothing special, just contains a static control in which I display text. It has a title bar so I can move it around.
- I added a PreTranslateMessage handler to the main dialog and check for the WM_MOUSEMOVE message. If the point lies in the client rectangle of the chart control I display text in the chart info window (static control on that child dialog).
So far it works, just that when the mouse is over the chart info window, the main dialog does not receive any WM_MOUSEMOVE in PreTranslateMessage. I really don't understand why I receive message when I am over the chart control in the main dialog but not in the chart info window that is also a child of the main dialog. ??
I hope you get the 'picture', maybe a screenshot of the layout would help ? If so, how do I add an image to a post ?
thanks for all your help,
Louis.
|
|
|
|
|
Seems I found the problem.
There is a difference in using a dialog as a child of another dialog then using a basic control. What I did is that I substituted the chart info window (child dialog) for a CStatic control and now it works. Just that I don't have a title bar to move the control around...I should be able to find a way move it by clicking anywhere on it.
I beleive there must be a way to make a child dialog work as a basic control...I guess there is a message handler in the dialog that consumes the messages and are not relayed to the parent.
Louis.
|
|
|
|
|
I don't know if this will help. But in this entire thread, no one mentioned that a control is another window and only the window over which the mouse is moving gets the WM_MOUSEMOVE messages (not its parents).
You don't want to capture the mouse in your main window, because then your child windows will not receive mouse message (they will all go to your main window).
If you need to keep track of the cursor position, even when the mouse cursor is over a child window. Then you should start a timer in you main window (in this case your dialog window) and call GetCursorPos to get the screen coordinates of the cursor. Then there is an API function some where (I forgot the name of it), that can be used to get the handle of a window given the screen coordinates, that you need to call to determine which window you are over. If you need to display the coordinates, then you'll probably need to convert the screen coordinates to the local client coordinates.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Hello,
I would like to embed the functionality of the windows explorer (file manager) in a win32 application (no MFC). Specifically, assuming I already have a file tree control on the left side of the window, I would like to have a control which will display files and directories on the right, much like explorer does, with different view options (list, details, icons, thumbnails, etc.).
Is there a control like the Web Browser control I can embed in my app, or is it more complicated than that?
Thanks in advance.
Have no fear of perfection - You will never reach it
|
|
|
|
|
Salvador Dali wrote:
I would like to have a control which will display files and directories on the right, much like explorer does, with different view options (list, details, icons, thumbnails, etc.).
That would be a listview (i.e., SysListView32).
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Umm...can you be a little bit more specific on how one would go about using this? There doesn't seem to be a lot of related documentation around, except perhaps for modifying the standard windows file open/save dialogs.
Have no fear of perfection - You will never reach it
|
|
|
|