If you don't believe me then stop being lazy and ask on the microsoft forums, if you have a MSDN subscription go to support and see what it says.
The MFC source has been released & open sourced which gives you a clear indication of the commercial value, it comes free with Visual Studio 17 community edition.
You are still on version 14 and have been since 20 July 2015 and they managed the small update to deal with the Windows 10 issues which managed to get released with the last Visual Studio 17 update cycle on 6 March 2018. The update simply deals with legacy MFC calls that stopped working.
I should mention the old Win16 API still exist in windows 10 under much the same support and there are a lot of legacy programs that still work and there are also a lot that don't. I love the old 16bit API, I cut my teeth on it but I wouldn't recommend someone write a new development targeting it.
So we get into some tricky language about what is and what does support actually mean. I loved the above quote in the article
Or put a different way, there are no secret APIs being kept away from Windows developers.
We could put that another way, we have told you the API and we have no intention of adding it MFC but you can.
I will leave you to ponder thru all that and decide if I got it all wrong. I am not microsoft and I don't speak for them so ask them directly. As far as I know your old code will hopefully continue to work on Windows but you will have no access to the new features unless you write them yourself.
Put a debug point jsut after this line and look at string
SQLWCHAR* strSQL = (SQLWCHAR*)"SELECT Exchanges.[X Name], Exchanges.[X Full Name] FROM Exchanges;";
I am betting it comes out as garbage
Why... this code sequence below is a text string of char AKA 8 bits
"SELECT Exchanges.[X Name], Exchanges.[X Full Name] FROM Exchanges;"
I am betting that SQLWCHAR is a wide character AKA something that isn't 8 bits and you just forcibly typecast it.
I am guessing you have to forcibly typecast it because the compiler objected to you assigning it.
I am guessing that text needed to be .. the L at the start is very important
L"SELECT Exchanges.[X Name], Exchanges.[X Full Name] FROM Exchanges;"
Coming off VB you will have an issue that C++ won't hold your hand, strings are not held in both formats like they are in VB because it's slow and costs time and space. VB looks at which of the various forms it matches and will use that right one. There is a class in C++ that acts much like VB strings called CString which carries the strings in both form if you need training wheels, you could use it.
The other option is to become familar with #include <tchar.h> and the features it offers but don't mix it with CStrings if you go that path.
There are other bits that look suspiciously like you have forced typecast probably to get over a compiler error
I am looking at =====> (wchar_t*)dsnName
Go thru and work out what needs to be char and what needs to be wchar and write the constant strings in the correct form
One of the main reasons for using C++ in this case is the amount of realtime calculations that are designed into the app.
You're totally right about the strings!! The first thing I tried to do in C++ was get it to print 'Hello World' to the console window and I could figure out why that could be so bloody hard to do. Anyway, thanks for suggesting tchar.h. I will definitely spend some time with that. One of the more challenging things for me so far is just trying to find the library to be looking at.
We had considered going the MFC route but we're saving that as a last resort because it seemed very bloated. Thanks for the lack of support warning. Didn't know that.
Well, I did finally get it going with OLE DB. So well do some more testing and playing around with it but I think we're on our way.
In the above code, when i click on button, OnButtonSelect() is not getting called even i added the button notification message in Message Map. After investigation i understood, the Base class mentioned in Message map and my class is from CScrollView and it cannot inherit the button features.
If this is true, how can i access the button message in my function.
I want to create the buttons in runtime and want to do some operation based on the button click.
Is it possible to notify in case if my class is derived from CScrollView?
Hey, Many thanks. It was working fine if i give this as window in CButton Create. But on my window i am loading active x control and hence i am giving active x control object so that it will always render on top of the window.
If i give "this", the button will be visible, once i load the active x control, the control will be on top and button will go back and thats the reason i gave active x control object instead of "this"
I will investigate like how to render it on top of active x control window, by creating it on "this" window.
Even i gave the style of my button as push_button, why it appears as flat one without any push behavior. I added the button to the main window by this. I dint even loaded the active x control but even then it looks like flat button. Even i click on that button there is no depth i can see on it, there is no response from the button.
for (int i = 0; i <1; i++)
m_button[i].Create(_T("Hi"), BS_PUSHBUTTON | WS_CHILD, CRect(0, 250, 120, 300), this, 101);
My class is derived from CTabView. I dint added any view yet. Just on that window i created this button at the bottom , i mean on the tab control bar to simulate it as a tab.
My class is just derived from CTabView. I dint add any view or functionality except adding a button. Even though they are different, during button creation i gave "this" (which one does it refer? tab control or TabView) as the parent window. If "this" refers to tabcontrol then it should behave normally. right? Even i want to add button on TabControl bar itself but not on view.
You can see my window with tab control and the look of the button in below link. I just created a class which inherits from CTabView which created a window with tabcontrol and added a code to create a button at bottom of the window. But the button does not look like push button.
Instead of inheriting a class from CTabview, this time i inherited from CScrollView and created a button on it which you can see in below link. This button perfectly looks like pushbutton and when i click on the button, there is some interaction i can see, i.e., button movement in and out. You can even observe a border on this button since i clicked on it.
I created a class which inherits from CTabView as follows:
class CTabClass : public CTabView
m_CView = RUNTIME_CLASS(CDocumentView);
AddView(m_CView,_T("Tab2")); //this creating 2nd tab but throwing assertions and //finally crashing while accessing it.
I want only one view for all the tabs. Is it possible in MFC?
How many more times do you plan to repost this question? We have explained why this will not do what you want, and given some suggestions for finding an alternative approach. Please try some of those suggestions for yourself.
Yes, it could work, but not like you tried above ... think that m_CView is the same CView instance on every tab, which is impossible ... but you can try to create a new instance on every AddView call, something like that:
this is simplistic approach, that I wrote it just you see the point, but in a real situation, you have to elaborate this: create any instance of CYourView object you need, add every one of them in an array of pointers, and supply this pointers on AddView call as first argument. Do you understand what I say ?
And the solution that I just give you is more as you see why your approach is not working than to be applied in your application ... because the creation of your CYourView is not that simple ... they must be attached at you CDocument, and so on ...
Because you have problems in completing your task, this reveal that your approach is not right ... you have to think to another ...
Last Visit: 18-Nov-18 15:06 Last Update: 18-Nov-18 15:06