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

C++ Migration Problems Windows 8.1 to Universal App

$
0
0

I tried to migrate 2 of my C++ Windows Store Applications from Windows 8.1 to Windows 10 this weekend and found that my user interface bindings were inoperable.

I build and update instances of my view model classes in the continuations of create_task() calls that I use to call FilePicker and StorageFile member functions.  I have about 100 of these and they all worked fine in Windows 8.1.  I have been using them in production for several months.

When I migrated the code.  The continuations threw exceptions when I tried to reference or update model view classes. The exceptions indicated that the continuations were running on a different thread and did not have access to the information needed to type cast the WinRT objects that I was using in my view model and that they were being marshaled by a different thread. 

I tried disconnecting the view model (Not setting its DataContext property) from my user interface.  When I did that the exceptions moved down stream.  The calls that I used to build the view model Collections seemed to be working but I received exceptions when I tried to reference or update any of my view model properties.

I received exceptions when I tried to open a popup menu from inside a create_task() continuation.

The tried the function calls that were throwing the exceptions outside of create_task() continuations and they worked fine.

Can you tell me what I need to do the resolve the problem.  Is there a way to get them on a thread that has access to the view model memory and the information needed to the runtime type casting that they need to do.

The problem seems ironic because the objective of create_task() is to improve user interface performance.  The issue has rendered it inoperable.

Thank you in advance for your help

Craig

 

C++ code equivalent of sample C# code

$
0
0

Can anybody make C++ code eqivalent of following C# code?

    class Plus
    {
        private int x;
        private int y;
        public int X
        {
            get { return x; }
            set { x = value; }
        }
        public int Y
        {
            get { return y; }
            set { y = value; }
        }
        public int plus()
        {
            return (x + y);
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            Plus p = new Plus();
            p.X = 1;
            p.Y = 2;
            Console.WriteLine("result : {0} ", p.plus());
        }
    }

This C# code is not useful program but I'd like to brush up on C++ here.


VC++6.0 Application crash

$
0
0

Hi,

I have an application which has UI in VB6.0 and some DLLs in VC++6.0

I am facing some issues in this application in windows 7. In windows XP this application works fine in release mode,but it crashes in Debug mode.In windows 7 this crashes with a message UI stopped responding.This happens for a particular operation which is done by one of the C++ DLLs.

    

void Invoke( void* pInputParms )
{  
  try {
    auto_ptr<RManager>
      pMgr( new RManager( ( RParametersInput* )pInputParms ) );

    pMgr->run();
//In debug mode it crashes here while auto_ptr tries to delete pMgr


  }

-----------------------

                  

void
RManager::run( void )
{
  try {

    logProjectMsg( "Start", PM_PROJ_START );

    RManagerDB* pDbMgr = pParserParms->getDBManager();


    pDbMgr->deleteTable( "ADNT" );

    bool hasErrors = false;
    int i,j,k;
    vector<RDialogProperties> dlgProps;

// Holds a list of dialogs that have proceses, and their INCLUDEd
// modules.
CDialogList * pDialogList = new CDialogList;

ResetProgressBar(sourceFiles.size());


    for( i=0; i<sourceFiles.size(); ++i ) 
{
 getParserParms()->setSourceFile( sourceFiles[ i ] );

      auto_ptr<TPreParserForADS>
        pParser( new TPreParserForADS( getParserParms() ) );

 pParser->m_pDialogList = pDialogList;
      ParserMessage mt = pParser->parse();

 SetProgressBar(1);

      if( mt != PM_MSGBOX_SUCCESS ) {
        hasErrors = true;
        continue;
      }    
-------------------------
--------------------------------------------------------  



    logProjectMsg( "PRE-PARSING HAS COMPLETED SUCCESSFULLY", PM_MSGBOX_SUCCESS );

  } catch( RException& ex ) {
    RManagerUI* pUIMgr = pParserParms->getUIManager();
    pUIMgr->writeLiveLog( ex.what(), PM_PARSE_ERROR );
  }
}

------------------------

This is the message I am

getting from event log(windows 7):

Faulting application name: App.exe, version: 2.20.0.14, time stamp: 0x556be7d8
Faulting module name: ntdll.dll, version: 6.1.7601.18798, time stamp: 0x5507b3e0
Exception code: 0xc0000374
Fault offset: 0x000cea0b
Faulting process id: 0x1db8
Faulting application start time: 0x01d0da4b26e91a1d
Faulting application path: C:\Projects\11thAug2015VC++DLLs\VC\App\Release\App.exe
Faulting module path: C:\windows\SysWOW64\ntdll.dll
Report Id: 87856dc7-463e-11e5-a178-00059a3c7a00

---------------------

In debug mode I'am getting following message(Windows XP)

---------------------------
Microsoft Visual C++
---------------------------
User breakpoint called from code at 0x7d61002d 
---------------------------
OK   
---------------------------

-------------------------

Could anyone say if anything wrong is here? I am a beginner in C++ and pointers.Please help with your suggestions

Error in Microsoft.CppCommon.targets

$
0
0

Recently I downloaded sample code for TWAIN Data Source from TWAIN.org.

This project was made for Visual Studio 2008.

I opened it from Visual Studio 2010, tried compiling but following error occurs at Microsoft.CppCommon.targets like attached screen capture.


This error seems to be the migration issue.

I posted my question on the TWAIN.org but there's no answer and I think this issue is regarding Visual Studio version.

(FYI, this project can be downloaded here by cliking twainds.source.2.1.3.zip)

Can anybody give me some idea or advice regarding this error?




Exporting a mostly native class through a .Net assembly

$
0
0

so I have a native class foofoo that inherit from a class from a class foo the only defined in another c++ library

public class foofoo : public foo
{
public:
	friend foohandle;
	foofoo(foodata& fd, bool GC);
	CliState(foodata& fd, bool GC, foohandle^ hand); //for derived types
	virtual ~foofoo();
	foohandle^ getHandle();
protected:
	msclr::gcroot<foohandle^> handle;
	bool const destGC;
};

what I would like to do is to inherit this class and the foohandle into another c++\cli assembly project like so

public ref class foobarhandle : public foohandle
{
...
};

class foobar : public foofoo
{
public:
	friend foobarhandle ;
	foobar(foodata& fd, bool GC);
	virtual ~DevivedCliState1(void);

};
I need to support vc++ 2010 

Compiling with toolset v100 x64 in VS2013: Getting TRK0002 error .... The handle is invalid.

$
0
0

I've got a library I wrote for some plugins.  Unfortunately, each of the plugins needs to be compiled with a different platform toolset. Specifically Maya needs v120, and Softimage needs v100 if it matters.

So compiling with the native toolset works as expected, but when I try to compile with v100, I get this error:

TRACKER : error TRK0002: Failed to execute command: ""C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\x86_amd64\CL.exe" @C:\Users\TFoxTD\AppData\Local\Temp\tmp756d62e9d0f94fec9a2700d3907d0255.rsp". The handle is invalid.

I do have VS2010 installed, but I'm trying to consolidate the build into one place


CWnd::PreTranslateMessage - override function

$
0
0

Hi,

I used the example of (https://support.microsoft.com/en-us/kb/222829) to create accelerators:

BEGIN_MESSAGE_MAP(CMainMenu, CWnd) ON_COMMAND(ID_EXPCATXML, &CMainMenu::OnExportCat) END_MESSAGE_MAP() CMainMenu menu; void CMainMenu::MenuItem() { ACCEL m_accel[1]; m_accel[0].fVirt = FCONTROL; m_accel[0].key = 0x45; // E m_accel[0].cmd = ID_EXPCATXML; menu.m_hAccelTable = CreateAcceleratorTable(m_accel, 1); // does not work

//menu.m_hAccelTable = LoadAccelerators(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_ACCELERATOR1)); // work CMenu *pMenu = AfxGetMainWnd()->GetMenu()->GetSubMenu(0); pMenu->InsertMenu(0, MF_BYPOSITION, ID_EXPCATXML, _T("Catalog to XML\tCtrl+E")); } void CMainMenu::OnExportCat() { AfxMessageBox(L"Test"); } BOOL CMFCApp::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) { if (menu.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo)) return TRUE; // otherwise, do default handling return CWinApp::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo); } BOOL CMFCApp::PreTranslateMessage(MSG *pMsg) { if (menu.m_hAccelTable) { if (::TranslateAccelerator(m_pMainWnd->m_hWnd, menu.m_hAccelTable, pMsg)) { return(TRUE); } } return CWinApp::PreTranslateMessage(pMsg); }



But my implementation does not work. Please correct me where I made a mistake.




C11 headers available in Visual Studio 2015. Out of no where.

$
0
0

Hi devs!

I recently installed Visual Studio 2015. I write C code. I know that MSVC compiler has very little support for C99, let alone C11.

The header files are located in Programs (x86) -> Visual Studio 14.0 -> VC -> include  as you all know.
But out of no where and I don't know how, I wrote #include <complex.h> and it didn't underline it. Intellisense was telling that it got it from C:\Program Files (x86)\Windows Kits\10\Include\10.0.10150.0\ucrt .

I opened the header files in Notepad, and it showed that these were C headers.
Will they actually work?


VS 2013 Pro - Compilor error in x64/release mode

$
0
0

The following code crashes at runtime in x64/release with "illegal instruction..."

  int h[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  int E=std::accumulate<int*,int>(h,h+16,0); // crash >=16
  std::cout << E << endl;

It does not crash in win32/debug,release or  x64/debug.
Similar crashes were reported before but not on this simple code. I hope update 5 would have fix it, it seems not.
I have version pro; win7.

I read somewhere that it is corrected in 2015 but I don't want to buy an upgrade (1283€*team size) for a MS's bug.

Hope an update will be soon available.

CListctrl with ComboBox and Column selection options

$
0
0

Hello,

Please suggest how to set CListCtrl or CMFCListcontrol with grid options,

I used LVS_REPORT view though it displays in grid format.

Apart from that I need to add ComobBox option to some selected columns.

and instead of rowwise selection to select only column by column.

Thanks for your help.

John


Johnson

Create the accelerator using SubclassWindow

$
0
0

Hi,
How to override the CWnd::PreTranslateMessage function if use to access the application throughSubclassWindow function?

bool Plugin::OnAppStartAfter(long CallParamBlock)
{
	CoInitialize(NULL);
	SessionId = app->StartSessionFromCallParams(&CallParamBlock);
	if (SessionId != 0)
	{
		m_pWnd = CWnd::FindWindow(_T("#32770"), _T("MobiScript"));

		if (m_pWnd != NULL)
		{
			ACCEL m_accel[2];
			m_pMenu = m_pWnd->GetMenu()->GetSubMenu(0)->GetSubMenu(6);
			if (m_pMenu != NULL)
			{
				m_pMenu->InsertMenu(0, MF_BYPOSITION, ID_EXPCATXML, _T("Catalog to XML\tCtrl+E"));
				m_accel[0].fVirt = FVIRTKEY | FCONTROL;
				m_accel[0].key = 0x45; // E
				m_accel[0].cmd = ID_EXPCATXML;
			}
			if (m_accel[0].cmd == ID_EXPCATXML)
			{
				m_hAccelTable = CreateAcceleratorTable(m_accel, 2);
			}
		}
		plugin.SubclassWindow(m_pWnd->m_hWnd);
	}
	CoUninitialize();
	return 1;
}

BOOL Plugin::PreTranslateMessage(MSG *pMsg)
{
	if (m_hAccelTable)
	{
		if (::TranslateAccelerator(m_pWnd->m_hWnd, m_hAccelTable, pMsg))
		{
			return(TRUE);
		}
	}
	return CWnd::PreTranslateMessage(pMsg);
}
Any ideas welcome, thanks


Visual Studio 2013 SP5 High DPI Aware MFC Application resize / redraw problem on Windows 8.1 Pro (all Updates installed) + Windows 10 Pro Insider Preview

$
0
0

Hello,
I created a MFC Application with Visual Studio 2013 Update 5 with the default settings and changed the Border Style of the About dialog to Resizing. On my first monitor 150 dpi (main monitor) all is fine when resizing the About dialog, on my second monitor 96 dpi resizing results in ugly / black lines (see screenshot) and sometimes the dialog disappears completely.

Tested on Windows 8.1 on real hardware and Windows 10 in VirtualBox 5.0.


Andreas

how do I launch Edge from my application.

$
0
0

Hi ALL,

I there any API to launch Edge or COM interface?

Also is there any detail documentation on windows app in windows desktop en?

Thanks


Thanks SOU

Show exports of a DLL

$
0
0

How can I, when I attached to a running process with Visual Studio, show the exports of the loaded DLLs to set breakpoints on certain functions. The only thing I found was the option to download symbols from the MS servers. In the good old days of the Watcom Debugger it was possible to show the exports of certain DLLs without loading any loading of symbols.

Thanks in advance,
Oliver S.

reinterpret_cast operator doesn't work on 64bit Windows server 2012 and Windows 10

$
0
0

using namespace std;
#include <stdio.h>


struct ShowLogArg_t {
char    m_strLogName;
int        m_ProcessHandle;
};

void myfunc( int test)
{
ShowLogArg_t & ShowLogArg = *reinterpret_cast<ShowLogArg_t *>(test);
printf("ShowLogArg.m_strLogName : %c\n",ShowLogArg.m_strLogName);
printf("ShowLogArg. m_ProcessHandle : %d\n",ShowLogArg. m_ProcessHandle);
}

int main()
{

ShowLogArg_t ShowLogArg;
int test;
ShowLogArg.m_strLogName='a';
ShowLogArg.m_ProcessHandle=0;
test = reinterpret_cast<int>(&ShowLogArg);
myfunc(test);
return(0);
}

The above program works fine on Windows server 2012 and Windows 10 when built in 32-bit mode using VS2012.

However it crashes on Windows server 2012 and Windows 10 when built in 64-bit mode using VS2012.

This behavior is a regression as the 64bit binary of the sample program works fine with Windows Server 2008 R2 and

backwards. 

Please fix this issue as it crashes our product on Windows server 2012 and Windows 10.

Whereas our product works fine on older version of Windows.


How to design UI for cross-platform development using C++ in Visual Studio 2015

$
0
0

Hi all,

I'm learning to use Visual studio 2015 for cross-platform development but It seem doesn't have much tutorial about it. I plan for use C++ to develop my application and the default native-activity is OK. Then I can't find where I can edit the UI of the application.

Please tell me how can I design the UI for my app that is native-activity application in C++?

Thanks.

output screen flashes after using getch();

$
0
0

Hi,

I am new to C++ and doing the first tutorial in my book. When I add #include<conio.h> at the top of the file and getch(); at the bottom my console window still flashes. Anyone know how to make it stop?

// A first C++ program demonstrating variable use.

#include"stdafx.h"

#include<conio.h>

#include<iostream>

usingnamespace std;

int main()

{

int creditHours;

double gradePointAverage;

creditHours = 15;

gradePointAverage = 3.25;

cout << "The number of credit hours is "<< creditHours << endl;

cout << "The grade point average is "<< gradePointAverage << endl;

return 0;

getch();

}

GetLogicalProcessorInformationEx() does not return the correct configuration

$
0
0

Run msinfo32.exe and you get the processor topology assume it says it it 

Socket 0 core 4  logical processors 8

Socket 1 core 4  logical processors 8

Technically using GetLogicalProcessorInformationEx() one should be able to come up with one's own topology. What I found GetLogicalProcessorInformationEx() does not work consistently. System to system sometime it works and sometime it fails. Can anyone throw light as to why it produces erroneous data and how can I avoid it? How can i fix it so that on any system running Windows Server 2012 R2 it produces consistent output. I work for a large corporation and we make servers with multi sockets, multi core and many many logical processors. All of them run Windows Server 2012 R2 my tool works on many and files on many. 

In the example I gave above my tool saw it like

Socket 0 core 7 processor 14

Socket 1 core 1 processor 2

I have no control over this as an application the call GetLogicalProcessorInformationEx() is a black box to me. Any and all idea will be welcome

"Where" command how can I duplicate programmatically

$
0
0

I have a program  and it needs a tool to exist in the system. Example how do I find out if program abcd.exe is installed in a system? When I say installed it could have been just copied to the system in some random place but what has  been done is the "path" variable has been modified so abcd.exe can be run from anywhere. So if you are guaranteed of abcd.exe to be in the path as described by the path variable can you prgorammtically search it out and tell it exists? I dont need to know where it exists but just exists is fine. Please note All Program --> Control Panel --> Program & Features will not know about abcd.exe. It was manually copied to some random place but the path variable has been updated. Please advice

 

How to know the project style

$
0
0

I downloaded a C++ project from internet.

Can I know the project style(template) of this C++ project by checking Project Properties?

I mean I want to know if this project is MFC Application, ATL Project, MFC DLL or Class Library, MFC ActiveX Control...

Viewing all 15302 articles
Browse latest View live


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