|
_CRT_SECURE_NO_WARNINGS must be defined before the header files that use the macro are included. So put it on top of your source file before including any header files.
To set it for all files of a project, add it on top of stdafx.h (when using that) or add it to the preprocessor definitions of your project settings (Configuration Properties - C++ - Preprocessor - Preprocessor Definitions).
Decreasing the warning level does not help here because the warning is treated as an error. To treat them as warnings, set SDL Checks to No in your project settings (Configuration Properties - C++ - General).
Another option is disabling the warning by using a pragma statement:
#pragma warning(disable : 4996)
This is useful when using those deprecated functions only a few times because they can be disabled on function level:
#pragma warning(disable : 4996)
void SomeFunc()
{
}
#pragma warning(enable : 4996)
|
|
|
|
|
Thank you Sir for your kind help.It works after defining "_CRT_SECURE_NO_WARNINGS " before the header files.
|
|
|
|
|
A better solution would be to do what the message says and use the sprintf_s function to create formatted strings. Or even to use the STL libraries if this is C++.
|
|
|
|
|
Thank you Sir for your kind help.
|
|
|
|
|
Hi
I am a bit confused about the double pointer.
I would like to pass it to a function and change the pointer value:
static int GetValue(int** hello)
{
*hello = &Something;
}
int* pointer = NULL;
GetValue(&pointer);
int** pointer = NULL;
GetValue(pointer);
To me they seem like the same thing.
|
|
|
|
|
elelont2 wrote: To me they seem like the same thing. No, they are totally different.
Case 1:
You create a pointer that will point to an integer variable, and pass its address to the function. The function then stores the address of a variable inside the pointer. On return the pointer now points to the variable, and the variable contains a value.
Case 2:
You create a pointer that will point to a pointer but is currently NULL. So when you pass it to the function the function gets a NULL value.
Simply put, in case 1, hello points to the address of pointer, in case 2, hello contains NULL. If you step through the code with your debugger it should become clear.
|
|
|
|
|
Hi all,
I have an MDI application under MFC. When I click on a menu I have a dialog based view (CDialog) which contains a button. What I need is when I click the button I want to resize my Dialog and set it to a new position.
I tried the MoveWindow, SetWindowPos but nothing changed. I think that those functions don't work with MDI or I missed sthing.
So people: How can I resize and move my Dialog to a new location point.
Thank you in advance.
"The Only Limit Is Only Your Imagination."
|
|
|
|
|
Moving the dialog by code should work like moving it by mouse. This does not depend on the application type.
Resizing is disabled for CDialog derived classes. To be resizable the window must have a different style (you may search for resizable dialogs). But it usually requires a lot of code to implement resizing with dialogs. It may be simpler to create your own window class that is not CDialog based (especially when it should be non-modal).
[EDIT]
You may have a look at these CP articles: CResizableDialog[^] and ResizableLib[^].
modified 8-Dec-15 5:40am.
|
|
|
|
|
Thank you, works like a charm.
"The Only Limit Is Only Your Imagination."
|
|
|
|
|
Hi,
I am just to trying to customize folder selection dialog by deriving a class from CFolderPickerDialog in VS2012. But VS2012 Wizard does not provide the option to add class with base class from CFolderPickerDialog. The base class list in Add Class wizard does not contain this class CFolderPickerDialog. Any idea why this base class is missing?
Also i tried manually added a derived class with CFolderPickerDialog as base class with correct message map related maros, function etc. But still i cannot get WM_TIME event handler, OnInitDialog is getting called in derived class. If anybody having any ides pls let me know.
Thanks,
Prasanth
|
|
|
|
|
The CFolderPickerDialog class inherits from CFileDialog[^], you should check there for details on customisation.
|
|
|
|
|
|
I have a video which I want to split into 4 parts according to the coordinate values while transmitting it from 1 device to another.
So how can I do that? Please someone help me.
|
|
|
|
|
|
I've read the following statement and I cannot understand something within it "In all binary trees, there are at most 2^i nodes at level i + 1" what I cannot understand is that tree's levels start at level 0, however, if we apply what is written in this statement there will be no level 0 at all as it says level i + 1 which mean 0 + 1 = level 1, 1 + 1 = level 2, etc. So is this statement wrong?!!! or I am missing something?!!!
|
|
|
|
|
Where did you read that?
Here[^], for instance, is stated: In general, each level of a binary tree can have, at most, 2N nodes, where N is the level of the tree
|
|
|
|
|
I read it in 2 books "Data Structures Through C in Depth" and "Data Structures and Algorithms in C++, 4th Edition" and even the link you gave to me saying "The root of the tree, therefore, is at level 0" which means that tree's level starts at 0. So I am confused because those books also saying that tree's level starts at 0?!!!
|
|
|
|
|
Well, that's correct if you say 2N (instead of 2(N-1)) as maximum number of nodes at level N.
|
|
|
|
|
I know it is correct to say 2^N, however, to say for level N+1 is what makes me confused because tree's level starts at level 0 which mean that N = 0 so if we apply the above statement it will be 2^0 for level 0 + 1 which means 1 node for level number 1 I hope you get what I meant
|
|
|
|
|
I know it is correct to say 2^N, however, to say for level N+1 is what makes me confused because tree's level starts at level 0 which mean that N = 0 so if we apply the above statement it will be 2^0 for level 0 + 1 which means 1 node for level number 1 I hope you get what I meant.
|
|
|
|
|
* Level 0 2^0 = 1 node
/ \
/ \
/ \
* * Level 1 2^1 = 2 nodes
/ \ / \
* * * * Level 2 2^2 = 4 nodes
It is 2<sup>N</sup> for level N .
If you find written 2<sup>N-1</sup> then levels are numbered differently, starting from 1 (instead of 0 ).
|
|
|
|
|
Thanks for your reply I just get confused a little bit as some books state that level start at 0 and others state that level starts at 1. We need a unified solution between those authors 
|
|
|
|
|
You are welcome.
|
|
|
|
|
I have a service I wrote that uses a filewatcher. On create it takes the excel file and truncates table and import it.
It works on my Windows 7 box. When I drag a new file into the folder it imports it. If i drag a newer file it deletes the old data and imports the new data.
On Windows 2012 Server the service works on the first import. on the second drop of a excel file I get
Error durring import of file 20151106.xls
Exception occured in Microsoft JET Database Engine
Exception: The Microsoft Jet database engine cannot open the file. It is already opened exclusively by another user, or you need permission to view its data.
This shouldnt happen as I have
finally
{
if (oraConn.State == ConnectionState.Open)
{
oraConn.Close();
}
if (oleDbConn.State == ConnectionState.Open)
{
oleDbConn.Close();
}
oraConn.Dispose();
oleDbCmd.Dispose();
oleDbConn.Dispose();
}
The service works fine on my windows 7 box and works for the first file on Windows 2012 server. Why is the service leaving the connection oleDbConn open on Windows Enterprise Server 2012? ?
modified 4-Dec-15 19:07pm.
|
|
|
|
|
I have a large legacy application being updated to use newer CMFCRibbonBar. This application is large and the creation of the CMFCRibbonBar involves converting a lot of legacy icons and menu structures so is a bit complicated to extract and post here. I will add further details as people request them.
But the general gist is:
The application works fine and has a valid and working CMFCRibbonBar.
That ribbon bar has 11 categories across the top. With hundreds of panel buttons and menu buttons.
I have also recreated the same structure using CMFCRibbonButton to create a quick old style menu system which has been added to the m_wndRibbonBar via the AddToTabs. This give me a working drop down menu in the top right had corner. I believe there is a general web example which people may be familiar with which create a “window style” dropdown where you to change the MFC window manager style from windows 2000 through to windows7.
My menu is created from scratch at application startup and is not taken from a menu resource as this application predates this structure.
I use commands like the following to construct this menu:
pQuickMenu = new CMFCRibbonButton(ID_MENU++,TEXT("Quick Menu"),-1,-1,0);
…
pQuickButton = new CMFCRibbonButton(ID_MENU++,wMenuCommand,-1,-1,0);
pQuickMenu->AddSubItem(pQuickButton,-1);
…
…
m_wndRibbonBar.AddToTabs(pQuickMenu);
The problem I am having is dynamically adding new buttons to this quick menu at a later date.
When I originally created this quick menu I kept the pointer to this structure that was used to add to the ribbon. Therefore I am able to add to the quickmenu.
pQuickBut = new CMFCRibbonButton(ID_MENU,wMenuCommand,NULL,0,hSmall,0,0);
pQuickMenu->AddSubItem(pQuickBut,ilp);
If I add a new button to the existing stored top level quick menu using the stored pQuickMenu pointer, the button does appear. The text is correct and the button is selectable.
Except that the button is not operated upon when clicked.
If I add the button to the m_wndRibbonBar instead then it works so I know there is a valid command handler.
Down within the MFC code, clicking on my new quick access menu enters a routine called:
CMFCRibbonBaseElement::NotifyCommand(BOOL bWithDelay)
This extracts the command id correctly.
UINT uiID = GetNotifyID();
But it then checks for a valid ribbonbar.
CMFCRibbonBar* pRibbonBar = GetTopLevelRibbonBar();
This fails and returns a null pointer. Thus the command processing structure is exited.
As a test, if I call m_wndRibbonBar.AddToTabs(pQuickMenu) again for a second time adding the same menu to the RibbonBar a second time, then the origial becomes corrupt but the new command does work.
I am therefore assuming (guessing) that when the AddToTabs is called there is a ribbon handle stored with the commands. When I add directly to the existing structure after the original call to AddToTabs, a valid ribbon handle is not happening.
In the old style of things I would detach my quick menu, update it and then reattach. But I do not know how to do this (or even if it is nessesary) in the new CMFC classes.
The command: m_wndRibbonBar.removeallfromtabs(); deletes the whole of my pQuickMenu structure so I can not then add to it.
Is there anyone who can help explain how to dynamicaly add new buttons to an exising menu that has been added to a ribbonbar tab.
Any help appreciated.
Thanks.
Steve.
-- modified 7-Dec-15 4:13am.
|
|
|
|