Quantcast
Channel: Visual C forum
Viewing all 15302 articles
Browse latest View live

How to fix "E2140 expression must have integral or unscoped enum type"

$
0
0

I have a function that calculates the monthly payments needed to pay off a loan however when ever I try to run the program, I get this error, "E2140 expression must have integral or unscoped enum type". I think it has something to do with the mismatch of ints and floats in the expression. However if that is the case, why would it cause an error if the number being calculated is being stored into MonthlyPayment which is of type float.

float CalculatePeriodicPayment(float LoanAmount, int Years, float Interest)
{
    int Months = 12;
    float MonthlyPayment;
    float I = (Interest / Months);
    MonthlyPayment = ((LoanAmount * I) / (1 - (1 + I)) ^ -Months * Years); //Line Error is thrown
    return MonthlyPayment;
}


Recht



Track click event

$
0
0

Hi,

In my MDI application I have a button in a CDockablePane. When clicking the button I am displaying a popup modeless dialog . When clicking outside of the newly created popup dialog I am destroying that dialog.

In the newly created dialog, I overrode the OnActivate() and when getting  nstate as WA_INACTIVE, I am destroying the dialog.

Now My requirement is 

1. When I click the button second time if the popup dialog is destroyed by clicking outside of the dialog other than this button, I have to display the popup dialog again.

2.When I click the button second time if the popup dialog is destroyed by clicking on this button , I should not display the dialog.

OnActivate event of the new popup dialog is getting called before the OnButtonClick of theCDockablePane. Whenever I go to OnButtonClick the new popup dialog is in destroyed state only.

In onActivate the pWndOther is always giving cmainframe window when nstate is WA_INACTIVE.

How to get whether user clicked on the button or any other control or dialog or mainframe or view?

Wheras if the parent is CDialog instead of  CDockablepane when clicking the button second time OnActivate event of the new popup dialog is getting called and OnButtonClick  is not getting called.

Please help me to meet my requirement.


How to create popup listbox?

$
0
0

Hi,

In my MDI application I have a button in a CDockablePane. When clicking the button I have diaply a popup listbox with image and text.

Is it possible to create popup listbox by subclassing CListBox?

Accessing registry in Windows 10 S

$
0
0
I am aware that trying to access Windows registry will be blocked on Windows 10 S. But I heard this can be overcome by using Node.js . Is there anyway one can access registry from a C++ component on Windows 10 S?

How can I re-create (or refresh) the Class Wizard in an MFC app?

$
0
0

Pretty basic:

I made some changes to the source code of a 64bit MFC application and need to re-create (destroy and build a new) class wizard. I am using Visual Studio 2017 version 15.9.3.

Any pointers?

Thanks,

Juan


Juan Dent

Vtable layout and binary compatibility

$
0
0

//DLL code(Version 1) class base { protected: EXPORT_ATTRIBUTE virtual void disp1(); EXPORT_ATTRIBUTE virtual void disp2(); public: EXPORT_ATTRIBUTE virtual void fun1(); EXPORT_ATTRIBUTE virtual void fun2(); }; class derived: public base { public: EXPORT_ATTRIBUTE virtual void fun1(); EXPORT_ATTRIBUTE virtual void fun2(); }; //EXE code int _tmain(int argc, _TCHAR* argv[]) { base *bPtr = new derived; bptr->fun1(); bptr->fun2(); }//Works fine //Later i changed the DLL code:(Version 2) class base { protected: EXPORT_ATTRIBUTE virtual void disp1(); EXPORT_ATTRIBUTE virtual void disp2(); EXPORT_ATTRIBUTE virtual void disp3();//Added new virtual method public: EXPORT_ATTRIBUTE virtual void fun1(); EXPORT_ATTRIBUTE virtual void fun3();//Added new virtual method EXPORT_ATTRIBUTE virtual void fun2(); }; class derived: public base { public: EXPORT_ATTRIBUTE virtual void fun1(); EXPORT_ATTRIBUTE virtual void fun3();//In derived as well EXPORT_ATTRIBUTE virtual void fun2(); };


And i have not recompiled the EXE code so its still referringto the first version of the DLL. But still this exe works fine with the version 2 DLL.

I heard that adding new virtual function in between other funtions in base will break the binary compatibility as the layout

of the vtable is changed in DLL and exe still referring to old vtable layout.

Could someone please help me to understand how this works without recompilation of the executable? I am using Visual studio 2013

for compilation.



Niranjan

Exception 0xc0000417 before main() is called, debugger doesn't catch it, out of ideas.

$
0
0

Hi, I have a very strange problem. We have a 32-bit console app that used to compile and run fine. It's a console build of a Win32 GUI app built as 64-bit, no GUI code is included. Now, after a few months worth of code changes to the 64-bit build, the 32-bit will build and link, but when run inside or outside a debugger, it loads but immediately exits with code  -1073740777 (0xc0000417). Searching for that error just brings up some useless non-developer pages. I can enable all native exception handlers for the debugger in VS2017 but that doesn't help. There are a number of globals in the system that have some code in the constructors, but I haven't inventoried all of these yet. I would expect the debugger to help here, but it's useless. Where can I find the list of global objects that would be initialized before main() as defined in the EXE?

Help! Thanks.

Dave

Validation of Special characters in Japanese language in VC++ & C#

$
0
0

How to Validate Japanese Special Characters in vc++ as well as in C#.

In Current Project for multilingual support I am using IsCharAlphaNumeric() API to validate Special Characters. For Japanese the same API is not working. Anybody gives idea to validate Special characters in Japanese Language.

All suggestions are welcome!!


How much it is safe to store and reuse the iterator values of map in another map?

$
0
0

Hi,

How much it is safe to store and reuse the iterator values of map in another map?

map<BYTE,vector<connections*>*> mconnections1;//sorting connections based on device key.
for (map<Device*,vector<connections*>>::iterator it=m_eip.m_mvpConnections.begin(); it!=m_eip.m_mvpConnections.end(); ++it)
		mConnections1[it->first->DEVICE_KEY]=&it->second;
for (map<BYTE,vector<connections*>*>::iterator it=mConnections1.begin(); it!=mConnections1.end(); ++it){
for(unsigned int i=0;i<it->second->size();i++) it->second->at(i)->Write(&fp);
}

Thanks

"Error 'SetWindowTextA': is not a member of 'CStatic' AND char *fgets(char*, int, FILE*): can not convert argument 1 from 'TCHAR' to 'char*'

$
0
0

Hi,

I migrated my C++ project from Visual Studio 2005 to Visual Studio 2017 Professional and when i build in Debug and Release modes i am getting the below errors:

1.

In the Debug build when I use SetWindowTextA like as shown below, I am getting the error "Error C2039 'SetWindowTextA': is not a member of 'CStatic'

m_status_text.SetWindowTextA(theStr);

m_status_text is declared as CStatic like as shown below:

CStatic m_status_text;

If I use SetWindowTextW, it is throwing an error in the Release Build.

m_status_text.SetWindowTextW(theStr);

When I changed it to "SetWindowText" like as shown below it is working for both Debug and Release Builds. Is it the correct way?

m_status_text.SetWindowText(theStr);

As far as my knowledge when we use "SetWindowText", in the Unicode format it treats it as "SetWindowTextW" and for multibyte character set format it treats as "SetWindowTextA".

But how SetWindowText works for Debug and Release builds?

2.

And also Can we use "_fgetts" instead of "fgets" (For release build) "fgetws" (For debug build) as in Debug build if i use "fgets", i am getting the below error:

char fgets(char, int, FILE*): can not convert argument 1 from 'TCHAR[260]' to 'char*'

fgets(currDir,MAX_PATH,f);// For release build
fgetws(currDir, MAX_PATH, f);// For Debug build
  1. Can I use "_tfopen" instead of "fopen" (For release build) and "_wfopen" (For debug build)

    f = _tfopen(fileName, _T("r"));

In place of

f = fopen(fileName,"r");// For release build
f = _wfopen(fileName, L"r");// For Debug build

Please help me on this.

How to check if a rectangle falls with in another rectangle.

$
0
0

Hi,

I have two rectangles. some area of one rectangle is placed within another rectangle.

How to check whether the rectangle area  is falls within big rectangle using MFC CRect  class?

Thanks


I got stuck at sorting algorithm

$
0
0

Selection algorithm i am stuck.

1. for (i = 0; i < size - 1; i++)
2. for (j = i + 1; j < size; j++)

Can you please explain. the line number 1 and 2?

what will be j value 

j = i + 1

#include <stdio.h>
#include <stdlib.h>
#define SIZE 10
void main()
{
    int a[SIZE] = {8,5,2,3,1,6,9,4,0,7};
void selection_sort(int* a,const int size)
{
    int i, j, min;
    for (i = 0; i < size - 1; i++)
    {
        min = i;
        for (j = i + 1; j < size; j++)
        {
            if (a[j] < a[min])
            {
                min = j;
            }
        }
        swap(&a[i], &a[min]);
    }
}
/*
    display array content
*/


How to identify that IPV6 is enabled or disabled?

$
0
0

Hi All,

How can we identify that IPV6 is enabled or disabled on a machine? Kindly share the C++ code portions. Did some googling but all are showing related to enumerate protocols/address family, but those are not helpful to identify that IPV6 is enabled or disabled.

Thanks,

R-V-R

Difference for a statement with or without curly braces in c++

$
0
0

int D = rand() % 4;

I am getting the random variable for the above statement, but if I put curly braces as shown below

{int D = rand() % 4;}

I always get D=0. Can anyone explain how to deal with this problem in c++

test.obj : fatal error LNK1276: Invalid directive'test' found : does not start with ‘/’

$
0
0

I work upgrade VS6.0 -> VS 2017 code.

this err, i checekd project option and i think no problem.

what to do next?


How would you create the following window ?

$
0
0

Can someone describe what would be the best means of creating the following window. The main window belongs to program called FTP Commander. I would to recreate the following window using Visual Studio 2015.What I am looking for is someone who can describe in detail as possible how I should go about recreating the following window as seen below ? Thanks. Victor.

I THINK I MADE A HUGE MISTAKE PLEASE HELP!!

$
0
0
Upon purchasing a used <g class="gr_ gr_73 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace" data-gr-id="73" id="73">laptop .</g>Asus A6 AMD Radeon Hd 7670 m <g class="gr_ gr_67 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="67" id="67">hd</g> graphics deleted mostly all of my visual c++ witch <g class="gr_ gr_70 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" data-gr-id="70" id="70">i</g> originally only had about 3 on there when gotten the <g class="gr_ gr_66 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="66" id="66">asus</g> This all began with <g class="gr_ gr_68 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="68" id="68">gta</g> 4 and <g class="gr_ gr_69 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" data-gr-id="69" id="69">gta</g> 5 off of steam and led to me deleting these. Can someone tell me what to do because this is affecting my whole computer

Need KB976656 for Visual Studio 2010

$
0
0

Hi,

One of our vcxproj is failing with ICE.   WE are building the solution with VS 2010 SP1.  I have searched and found the KB976656 for VS 2008.  But unable to find the similar one for VS 2010.

I tried disabling the optimization and turned off Pre compiled header files, but no use.  The solution is failing with ICE.

I have found the below thread for VS 2013 but not for the VS 2010.

Please guide me to the similar thread for VS 2010.

Regards,

IPropertySetStorage / IPropertStorage Interfaces.

$
0
0

Hello, 

           I have successfully applied custom properties to a file .It works fine after writing and reading the properties. But when I modify/Edit the file all the custom properties are lost .Any solution to retain the properties after modifying the file?

Thnk you in advance!

VS 2015 unresolved external when linking to odbc libs

$
0
0

Hi,

I'm trying to compile GDAL (http://www.gdal.org/) with VS 2015 Preview. Currently I'm stuck with an unresolved external from odbccp32.lib, obviously resulting in the crt changes in the 14.0 compiler.

Here's the message:

odbccp32.lib(dllload.obj) : error LNK2019: unresolved external symbol __vsnwprintf_s referenced in function _StringCchPrintfW

I compiled from the VS2014 x86 Native Tools command prompt. The lib comes from

C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86

This SDK must have been installed with VS 2015 Preview (or VS 2014 CTP).

Is there a newer SDK version or how can I solve the problem?

Cheers,

Thomas

Viewing all 15302 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>