|
Class object limit? What's that?
|
|
|
|
|
Have you tried catching std::bad_alloc exception?
|
|
|
|
|
what is the value of y after the following statements?
float y;
y = 17 / 5;
|
|
|
|
|
Probably 3 , because you're dividing two integers and then storing the resulting integer in a float .
But why don't you run it for yourself and find out?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
As Richard said, the expression only contains integers and so you should get the result of an integer division (3).
However, if at least one of the operands / variables are of float type, all integers will be automatically converted to float type.
Say, for example - y = (float)17 / 5;
Having said this, the answer may be slightly different from the expected 3.4 because of how floating point numbers are represented.
Please check this - Floating point inaccuracy examples - Stack Overflow[^]
«_Superman_»
I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) (October 2009 - September 2013) Polymorphism in C
|
|
|
|
|
I have USB drive inserted in computer. My application should be notified when user click in eject button from system tray.
Is there any way to get notification?
|
|
|
|
|
|
Very good reply! That is a little known and obscure part of the win API.
|
|
|
|
|
|
Randor wrote: maybe Jochen Arndt[^] is a bot?
By his profile picture, he's a boot (or possibly a pair of them)
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
It is still a little known and obscure part of the API.
|
|
|
|
|
Thanks Jochen,
WM_DEVICECHANGE message is to handle device removal and insertion event. But my requirement is something different.
I want to handle a notification when user click on "eject" option from system tray. This event should occur before WM_DEVICECHANGE I think.
Please help me to do so.
|
|
|
|
|
It can be also received by the WM_DEVICECHANGE handler as DBT_DEVICEQUERYREMOVE , DBT_DEVICEREMOVEPENDING , or DBT_CUSTOMEVENT .
This requires calling RegisterDeviceNotification with appropriate settings. But that will not support volumes (DBT_DEVTYP_VOLUME ) because arrival and removal evens are send by default. The only solution I know is opening a device handle for the USB drive and using that to register. Than you will get informed about the eject request and can reject the request or accept it after closing the device handle. See Device Events (Windows)[^].
|
|
|
|
|
Thanks Jochen,
Your approach worked well with MFC application but same approach not working with windows service. Any clue?
|
|
|
|
|
See RegisterDeviceNotification function (Windows)[^]:
Quote: Services can use the RegisterDeviceNotification function to register to receive device notifications. If a service specifies a window handle in the hRecipient parameter, the notifications are sent to the window procedure. If hRecipient is a service status handle, SERVICE_CONTROL_DEVICEEVENT notifications are sent to the service control handler. For more information about the service control handler, see HandlerEx.
|
|
|
|
|
Hi,
There is an amazing amount of high quality information right here on codeproject dating back almost 18 years. Much of it is still relevant. Just use the search box up at the top of the page.
Receiving Device Event Notification in Windows Service[^]
Best Wishes,
-David Delaune
|
|
|
|
|
I create mdi application with splitter in MainFrame with two areas. In first area i suppose to a static control and MDI child windows in second. The CSplitterWnd is created, but i can`t create MDI child window in splitter panel. I have the following code in OnCreateClient function
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
if (!m_mainSplitter.CreateStatic(this, 1, 2, WS_VISIBLE | WS_CHILD, AFX_IDW_PANE_FIRST))
{
return FALSE;
}
if (!m_mainSplitter.CreateView(0, 0, RUNTIME_CLASS(CMDIAppView),
CSize(140, cr.Height()), pContext))
{
return FALSE;
}
if (!m_mainSplitter.CreateView(0, 1, RUNTIME_CLASS(CMDIAppView),
CSize(cr.Width()-140, cr.Height()), pContext))
{
return FALSE;
}
m_bInitSplitter = true;
return CreateClient(lpcs, NULL);
}
I try to change CChildFrame::OnCreate
with CWnd* pView = GetDlgItem(AFX_IDW_PANE_FIRST);
cs.hwndParent = pView->m_hWnd;
but i have a error. I think that CMDIAppView is corresponded to CMDiChild view area in MDI application and conflicted with created splitter, i tryed to create splitterview in another class but still unsuccessful.
I found article "SDI Application with MDI Child Windows in Static Splitter Pane" by John Z. Czopowik in codeguru but can not download source code from there. Please can anyone explane me how to create mdi child windows in splitter panel.
Mikle G.
email: mg17110081@gmail.com
|
|
|
|
|
Member 13277911 wrote: ...but i have a error. What error?
Member 13277911 wrote: ...but can not download source code from there. Why not? Can you get it from here instead?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
in codeguru SDI Application with MDI Child Windows in Static Splitter Pane i don't have permission to access on this server.
The error is
First-chance exception at 0x00D91166 in MDIAppView.exe: 0xC0000005: Access violation reading location 0x00000020.
if i add
cs.hwndParent = pView->m_hWnd;
to CChildFrame::PreCreateWindow
this error while MFC window creation i think.
may be subclass the child window can resolve this problem but i dont know how to
subclass MDIChild with panel.
i know that WTL can place mdichild window in CSplitterWnd
The suppose is to create MFC mdichild window with CSplitterWnd as parent
in MFC program.
|
|
|
|
|
Thanks for program.
I think it helps in solution.
|
|
|
|
|
I'm working on an OpenGL application in C++. I have some code already written, but it's becoming a fairly complex project, and I want an easy way to scale it. I heard about MVC (I know I was exposed to MVC concepts when I learned OpenGL) and I read that graphics applications used MVC long before web. I don't know whether that was just the OpenGL part or if the whole application was being referred to. I'm thinking about the whole application, so I looked up MVC framework for C++ and found PureMVC, which looked pretty good, albeit with little to no tutorials and examples in C++.
So I'd like to know, is this a good idea?
More specifically:
1. would this cause the programme to take up extra system resources and cost FPS (or would it go faster),
2. is the PureMVC framework known to be stable or buggy (can I rely on it not to break my programme),
3. is it even good practice to use a second MVC in addition to the MVC used in OpenGL via GLM,
4. is PureMVC known to work on Ubuntu,
5. and if none of that is a problem, where can I find appropriate tutorials and examples to speed up the learning curve, preferably for MinGW/MSYS/Eclipse if they have compilation and linking instructions,
6. or is there something better than PureMVC I should use instead, which compiles on Windows and Ubuntu and is good for graphics applications?
Thanks.
|
|
|
|
|
Need to cover some basics which you haven't mentioned which is always slightly scary
1.) I assume you are talking new OpenGL that is 3.0+ not old style OpenGL
Old style has the glBegin glEnd etc the new style you can't do anything without a shader and you drag all the function implementation pointers yourself.
2.) On the new OpenGL, GLM is one library you can use for matrix and maths stuff that ultimately ends up out on the shader in a sort of MVC setup.
3.) PureMVC is aimed at breaking the processing up via a predictable framework generally so you can thread it or use multicores.
I take it your current code is a linear application so not something you can port easily to PureMVC you need to design it differently from the start.
The next problem is PureMVC can be problematic in some situations like you have a client app interface sitting on a server which really has all the models. So the model view is handed to the client via the server. Lots of CAD programs and network games work that way and PureMVC is limited to what it can do. You can sort of shim it but you lose much of the effect and there are better techniques.
So can you start with a basic what OpenGL version and how your app is setup (models are where?) and when you say scale up what do you mean (more users, more processor cores)?
In vino veritas
modified 30-Jul-17 9:59am.
|
|
|
|
|
Thanks for the advice.
When I was talking about scale, I was talking about my codebase. I was getting to the point where I had more than a few things working to together. I'm not confident in the way I'm organising it, and I'm having a little trouble even visualising how to put it all together efficiently and effectively.
I thought MVC might make all that go away. Something handling multiple cores for me would be plus, which I think PureMVC is supposed to do.
It sounds like PureMVC is a bad idea for a game though, I guess I'll do it the normal way.
Thanks.
|
|
|
|
|
I will assume you are working with new OpenGL 3.3+ (If you aren't you need to switch now) you will have what amounts to a pile of Function pointers you will have got with wglGetProcAddress. Usually what you need to do is first start with that and put them in a class or object. Then build functionality on the class/object interface because you have everything contained. If you aren't comfortable with doing it yourself then use a library like GLEW which will wrangle all the function pointers for you. GLEW isn't great because you can't extend it easily but it's better than nothing.
If you haven't wrangled all the function pointers into a sort of API that is where you start.
Once you do that at a minimum you will be able to attach/change shaders and apply the matrixes to that class/object and it will store internally whatever it needs.
I usually set the class/object creation to take a window handle being the window you want to bind the OpenGL onto. The reason for doing that is when you run multiple windows each window will have it's own render context so you might as well bind the window into your object at construction. If you are using just one main OpenGL window the step will seem to have little benefit but the moment you start with multiple OpenGL windows you will get why you do it.
In vino veritas
|
|
|
|
|
How is more efficient to have, a CMap member variable created on the stack, or on the heap, even the values of CMap are just pointers:
CMap<int, int, CStringArray*, CStringArray*&> m_MapContactInfo;
or
CMap<int, int, CStringArray*, CStringArray*&>* m_pMapContactInfo;
knowing that this CMap could contain thousands of elements ...
|
|
|
|