|
Thank you Orjan,
yeh I was lurking the windef file and actually got this working:
struct opaque
{
int* data;
};
typedef opaque* opaque_ptr;
And then this works:
HWND wnd = GetSomeWindowHandle();
opaque_ptr h = reinterpret_cast<opaque_ptr>(wnd);
wnd = reinterpret_cast<HWND>(h);
But as you said, it feels like cheating. I'll give it further thought, and if I can't find anything else, I think I'll be using this approach.
Thanks again for the help! Best regards.
modified 10-Nov-14 13:14pm.
|
|
|
|
|
If you use a typedef of void* you will not need any reinterpret_cast calls, as it's all the same type. The problem of using a pointer to a struct like this is that someone looking at the code would be curious about what's in
h->data so it is misleading to have it if it's never used.
|
|
|
|
|
I've used a couple of way of getting around this:
- use the void pointer hack
- wrap every WIN32 operation in another class called window_handle then implement window classes as needed using that. I also replaced the concrete base class with an interface class as virtually all the code that would have been saved by implementation inheritance ended up in the window_handle. This is similar to your shared PIMPL but the PIMPL is actually a full blown object in its own right and does all the WIN32 stuff and doesn't just hide an HWND.
Another way I want to experiment with further decouples the windows guff from the logic of what the window actually does. The idea is to have a window class that has a message handler interface pointer but I haven't tried that yet. You'll be getting a similar effect using boost::signal2 to route messages.
|
|
|
|
|
Thank you Aescleal, I think I'll use the void pointer.
Aescleal wrote: The idea is to have a window class that has a message handler interface pointer but I haven't tried that yet.
I'm trying that just yet, and I have already subclassed some existing common controls to get their WndProc and route the messages accordingly through boost::singal2, but on my own terms. I think this is what Windows.Forms do.
Thanks for the help!
|
|
|
|
|
I have an SDI app (test app), where I spread an CGridCtrl ... I wonder how to catch CMyView::OnMouseMove , because I saw that this handler is never fired ... can you help me, please ?
|
|
|
|
|
I try that:
void CGridViewDemoView::OnMouseMove(UINT nFlags, CPoint point)
{
TRACE("aaaaaaaaaaaaaaaaaaaaaaaaaa\n");
CView::OnMouseMove(nFlags, point);
}
Taked from here.
|
|
|
|
|
You probably forgot to add the corresponding entry to your message map:
BEGIN_MESSAGE_MAP(CGridViewDemoView, CView)
ON_WM_MOUSEMOVE()
END_MESSAGE_MAP()
|
|
|
|
|
I did that:
BEGIN_MESSAGE_MAP(CGridViewDemoView, CView)
ON_WM_SIZE()
ON_COMMAND(ID_TOGGLE_READONLY, OnToggleReadonly)
ON_WM_ERASEBKGND()
ON_WM_MOUSEMOVE()
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
|
|
|
|
|
Then there are two other possible sources:
- The message is handled by a window that is over your view (e.g. the grid control).
- The mouse is captured by another window (using CWnd::SetCapture).
For the first case you should not add the handler to the view but to the grid control (which requires modifying the sources of the grid control or deriving a new class).
|
|
|
|
|
Was the first situation, and I extended CGridCtrl in order to not mess up CGridCtrl ... Thank you.
|
|
|
|
|
Does anybody know of any third party libraries that I can use to get the prices of call options on stocks? I would like quotes on put prices also?
Bob
|
|
|
|
|
Google is probably a better place to check.
Also, unless you are writing code in C/C++ to call the libraries then this forum wouldn't be the right place anyway.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Thanks for the response. I am writing C++ code and I am looking for a C++ callable library. Preferable an open source library. Also, before posting my question here, I did several searches using Google. However, they failed to turn up what I am looking for.
Bob
|
|
|
|
|
|
BobInNJ wrote: Does anybody know of any third party libraries that I can use to get the prices of call options on stocks?
Just to be clear whatever this is wrapped in, it still, of course, requires a service.
And the service, not the library, is going to be what the significant part of the cost is. And that will be a recurring cost. Not to mention of course that there will probably be other functionality associated with the service which is probably a significant consideration - for example how exactly they manage the money that must exist.
Since it is a service then it is probably best to look for the service or services that best meet the business needs and then look for libraries specific to those after that. If there is no C/C++ interface then write one.
|
|
|
|
|
How would a library provide such a feature? Stock prices are provided by stock exchanges, so it depends which exchange you are interested in, or if all of them, then you need to find a stock price service company. And then you will need to write some code to access their data feed, which will probably not be in C++.
|
|
|
|
|
float **deviation1;
deviation1=memory_alloc_2D(waveframesize,NUM_OF_COEFFICIENTS);
for(i=0;i<waveframesize;i++)
{
for(j=0;j<NUM_OF_COEFFICIENTS;j++)
{
deviation1[i][j]=w1[i][j];
}
}
freeArray(deviation1,waveframesize);
void freeArray(float **a, int m) {
int i;
for (i = 0; i < m; ++i) {
free(a[i]);
}
free(a);
}
I am trying to free the memory space of deviation but it seem not working cause the process is killed and while checking the running process for every loop the memory size is incremented..can someone suggest where i wen wrong?
|
|
|
|
|
You should show us the source of your memory_alloc_2D function.
In general it is better to free the most recently allocated memory first. That means the loop in your freeArray function should start at m-1 and decrement the loop variable until null.
|
|
|
|
|
I am hoping I do not get flamed for asking this here, but I am looking for answer and "use blink without delay" is not it.
I need to build, for emulation purpose, single bit B&W bitmap.
I like to start with 100x100 size.
Now since the processor I am using is 32 bits processor how should I organize the bits array - 8 bits wide or 32 bits wide or does it matter as long as I process it correctly?
I do understand that "real" bitmap provides some fills to make the array fit into selected width.
Thanks for your time.
Cheers Vaclav
|
|
|
|
|
Vaclav_Sal wrote: Now since the processor I am using is 32 bits processor how should I organize the bits array - 8 bits wide or 32 bits wide or does it matter as long as I process it correctly?
Doesn't really matter... the only thing that really matters is that it rests on an 8bit boundary, because computers can handle that more efficiently than anything else (since RAM is allocated on 8bit boundaries).
edit: What I mean by resting on an 8bit boundary means that if the sample resolution you're dealing with is one bit (or three bits) you'd still want to pack that to 8bits (fill the non-used bits even though you're not using them).
|
|
|
|
|
I would suggest that you make it 100 bits wide, rounded to the nearest 32 (i.e. 4 words). That will ensure that each row is aligned on a 32-bit boundary which is most efficient for this architecture.
|
|
|
|
|
Well, if you have to access each bit independently (i.e. sample-wise), bit packing is still way more efficient than doing block-wise packing.
|
|
|
|
|
Sorry, not sure what that means in relation to my suggestion.
|
|
|
|
|
Hi to all,
for my projects, sometimes i have to communicate with another computer, sometimes using serial port, sometimes using ethernet and so on: i had write some classes to use for this communication.
Last time, on july of this year, my "communication partner" ask me to give him my class to be sure we use the some method, but i work with VC++ and MFC and he works with old visual basic; from this question, there is a way to make a DLL for each class i have, which is used by old visual basic, VC++ (with this, i think there is no problem), C# and Delphi (these are the most used languages in my neighborhood) ? I have to re-write all classes removing the MFC functions, or it's possible leave them so ?
Thanks
|
|
|
|
|
DRUGODRF,
This is a great question. My initial thinking is that this is exactly the kind of situation that COM was developed for.
However, if you already have working DLLs that are adequate for your purposes, then re-writing the Communication components in COM, would be extremely time consuming.
I think the answer to your question depends on the output of the compiler used for whatever language employed, and the complexity (and compatibility of the type systems) of the communication class that you have designed.
My coding experience is mainly C++ and Assembly language,...and, so, I have no idea how a Visual Basic compiler would implement your component. But, I think that if the dependent libraries for your component exist on both computers, then it doesn't really matter if you use MFC or not,...the code execution will jump to the location address specified in the import table of your DLL for the invoked function.
But, the primary concern here is: just how reliable is this way of remote communication ???
modified 6-Nov-14 15:54pm.
|
|
|
|