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

CDialogBar

$
0
0

I am trying to work with CDialogBar. I followed the  instruction on the following link to change the base class from CDialog to CDialogBar:

  However when I execute the code the DialogBar does not show up, At this point I do not include the last step of the instruction:

----http://support.microsoft.com/kb/185672/en-us

I do not add the following code:

m_myDlgBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
            CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
         m_myDlgBar.EnableDocking(CBRS_ALIGN_ANY);
         DockControlBar(&m_myDlgBar);

If I try to add the above line, the part m_wndToolBar.GetBarStyle() give me an error. I cannot useGetBarStyle as a function.

I am using visual studio 2013... Could someone guide me to get this to work...

Thanks

YA


[Visual C++] Crash when using _vstprintf_s. Is there a bug?

$
0
0

Hi Guys,

I'm facing with issue in function _vstprintf_s.

I has written a simple program like below:

#include "stdafx.h"
#include <stdio.h>
#include "afx.h"

CString TestVSPrintf(const CString &msgFormat, ...){
	TCHAR buffer[256] = {0};
	va_list argprt;
	va_start(argprt, msgFormat);
	_vstprintf_s(buffer, 255, msgFormat, argprt);
	va_end(argprt);
	return buffer;
}

int _tmain(int argc, _TCHAR* argv[])
{
	CString d = TestVSPrintf("String: %s", "TestString");
	return 0;
}

It crashes while coming to line _vstprintf_s with bad pointer (0xcccccccc) access violation error.

I'm using Visual Studio 2005 SP1.

Are there any known issue?

c# to c++ equivalent code?

$
0
0

string[] separator = new string[] { "(---)" };

string[] trimData = data.Split(separator, StringSplitOptions.None);

anyone know a similar function in c++ to do this? or how to do this in c++?

Opening Remote media failed with standard user token

$
0
0
I have a COM exe which is starting along with Remote Desktop Connection(mstsc.exe). COM exe is used to receive notifications when a drive is added to the system or when removable media is inserted into a drive.Upon receipt of those notifications, I attempt to open the drive to query some properties from it.
For this, I used CreateFile() windows API as ::CreateFile( static_cast<LPCTSTR>( csDriveLetter ), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0 );
Where csDriveLetter is of the form \\\\.\\G:
 
CreateFile API fails with ERROR_ACCESS_DENIED(5), when mstsc.exe is started by standard user token in Windows Server 2008. But CreateFile API succeeds when mstsc.exe is started by standard user token in Windows 7.
If mstsc.exe is started by administrative user token, CreateFile API succeeds in Windows 7 as well as Windows Server 2008.
 
Why CreateFile API fails in Windows Server 2008 and succeeds in Windows 7, when mstsc.exe is started by a standard user token?

Thanks, Renjith V R

CRT initialization during explicit linking of dll using LoadLibrary

$
0
0

I have an intermittent issue,  when our dll is loaded (explicit) by the customer Application , it sometime throws the “Failed to initialize the CRT error R060”
As a fix, I am have put the following entry point _DllMainCRTStartup  ,  will this work at the customer site ?

I want to be sure before I send it to customer, as my earlier fixes did not work, or do anyone have any suggestions.
My dll is loaded explicitly using LoadLibrary 


CRecordSet and DEBUG output messages

$
0
0

Hi

Me again. Hope you don't mind! :(

I have had this code for years:

            strQuery = _T("SELECT * FROM [Public Talk Categories] WHERE [Category]='NS'");

            pRecords->Open(CRecordset::snapshot,(LPCTSTR)strQuery);


But in VS2013 in DEBUG mode when I look at the output window it reads:

First-chance exception at 0x00007FFEE3295BF8 in CommunityTalks_x64.exe: Microsoft C++ exception:
 CDBException at memory location 0x000000B88BECE5F0.
First-chance exception at 0x00007FFEE3295BF8 in 
CommunityTalks_x64.exe: Microsoft C++ exception: [rethrow] at memory location 0x0000000000000000.
First-chance exception at 0x00007FFEE3295BF8 in 
CommunityTalks_x64.exe: Microsoft C++ exception: CDBException at memory location 0x000000B88BECE5F0.
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dbcore.cpp(174) : AppMsg - Optional feature not implemented 
f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\dbcore.cpp(174) : AppMsg - State:S1C00,Native:106,Origin:[Microsoft][ODBC Microsoft Access Driver]

What does it mean? <scratches head>

Andrew

C++ question

$
0
0

Write a program by A program language (Any Language) to calculate Simple Interrest (SIMaturity Value (MV):

Formula1: Simple Interest (I) = Principal (P) x Rate (R) x Time (T)

Formula 2: Maturity Value (MV) = Principal (P) + Interest (I).

Example:

Jan Carley borrowed $30,000 for office furniture. The loan was for 6 months at an annual interest rate of 8%. What are Jan’s interest and maturity value?

 

 Solution:

SI = $30,000 x.08 x 6/12  = $1,200

MV = $30,000 + $1,200 = $31,200

visual studio 2013, MBCS and mfc

$
0
0
Does microsoft realise the consequence of depreciating MBCS in mission critical software? The consequence of every change from chat to wchar-t has to be examined. Is it no wonder that there are some people who do not want to change from XP?

InterlockedIncrement not found when using /clr and Windows 8.1 SDK in MFC dll VS 2012 project

$
0
0

I have a MFC DLL project in Visual Studio 2012 C++ that I am in need of using the /clr switch as the project uses a hybrid mix of native and managed C++ and calls into C# reference class libraries.  When I compile the project against the Window 8.0 SDK, all is good.  But when I try the Windows 8.1 SDK the project won't compile because it kicks out a bunch of missing entries related to InterlockedIncrement and InterlockedDecrement referenced by ATL classes.

C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include\atlsimpstr.h(93): error C3861: 'InterlockedIncrement': identifier not found

To replicate this issue...
1) Assumed that Visual Studio 2012 is installed, W8.0 SDK is installed at C:\Program Files (x86)\Windows Kits\8.0 and W8.1 SDK installed at C:\Program Files (x86)\Windows Kits\8.1
2) Create a Visual Studio 2012 MFC DLL project (defaults to MFCLibrary1)
3) Accept all defaults
4) From the Project properties...in Configuration Properties node...Common Language Runtime Support, select "Common Language Runtime Support (/clr)"
5) Use 8.0 SDK Include...From the Project properties...in C++ Directories clear out contents and paste in "C:\Program Files (x86)\Windows Kits\8.0\Include\um;C:\Program Files (x86)\Windows Kits\8.0\Include\shared;C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include;C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include;"
6) Compile the project, all is well.
7) Use 8.0 SDK Include...From the Project properties...in C++ Directories clear out contents and paste in "C:\Program Files (x86)\Windows Kits\8.1\Include\um;C:\Program Files (x86)\Windows Kits\8.1\Include\shared;C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include;C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include;"
8) Clean and Compile the project....error C3861: 'InterlockedIncrement': identifier not found

NOTE: I am aware that you should update the bin, lib, etc for a complete 8.0 vs 8.1 SDK project, but saved time omitting those steps.

Setting WINVER/_WIN32_WINNT to _WIN32_WINNT_WIN7 did not make a difference.

I might be able to get around this by defining InterlockedIncrement myself and then doing a GetProcAddress to dynamically call it but that isn't ideal and not sure if I am going to run into any additional issues.

mfc unicode

$
0
0

Hi,

I am using VS2013, MBCS is defined.

I have a txt file, the encoding is UTF8. There is ascii and Cyrillic text in the file. When I use fgetws, the ascii text is read fine but the Cyrillic text comes in as rubbish - that is it does not read it properly. It I load the file into notepad and change the encoding to UNICODE and save it. There is no difference.

A bit of history about the txt file: The file was originaly an ascii file, some of the ascii text was replaced by cyrillic text and returned in UTF8. The editing was done on an apple computer.

Any help gratefully appreciated

Internal compiler error

$
0
0

Hello,

I have a small problem. I am getting Fatal Error C1001: An internal error has occured in the compiler. (C++/CLI)

What now ? 

Protected member issue

$
0
0

I thought I understood "protected" but I am getting an error I don't understand.

I have a class with members declared as follows:

class EventBase
{
protected:
	typedef std::map<const char *, EventBase *, Stri_less>::iterator EventMapIter;
	static std::map<const char *, EventBase *, Stri_less> EventTypeMap;
    static std::map<const char *, EventBase *, Stri_less> fieldContextMap;
    char *fieldsContext;						
    char *eventType;                           

I have a derived class 

class EventSMF : public EventBase

In a member function of EventSMF I code

    std::string workString;

    for ( EventMapIter it = EventTypeMap.begin(); it != EventTypeMap.end(); it++ )
    {
        if (! workString.empty() ) workString.append(", ");
        workString.append(it->second->eventType+SMFtypeOffsetInContext);		// Drop the SMF_T
    }

I get the following error on the second .append():

error C2248: 'EventBase::eventType' : cannot access protected member declared in class 'EventBase'

Should not a protected member of a parent class be accessible in a derived class? Isn't that the whole point? Am I having an attack of stupid this morning?

Thanks,


Charles

Is OpenMP 2.0 maintained in VisualStudio 2013

$
0
0

Is OpenMP 2.0 maintained by Microsoft in VS2013?

Thanks,

Peter

how to block CDockablePane being resized

$
0
0

I've tried to use CDockablePane and overriding member function IsResizable, make it always returning FALSE, but causing assert error.

I have also tried define a new class deriving from CPane, but failed to display. There's few sample of using CPane.

I'm fresh in the new UI of MFC, any helpful information would be appreciated.


launching dialog from Command line is going to background in MFC application

$
0
0
I have an MFC application.
Which can display the dialog using systemtray menu and command lne option.
When i am openieng the dialog from systemtray it is always coming into foreground.
But when  iam opening from command line it is always going to background.

When the command is entered from command line,i am posting the message to display the dialog.
while posting it is going to background.In thi case also,when iam opening the dailog for first instance of the applciation it is coming to foreground.
But if the application inastance is already running,that time if i give the command again it is going to background always.
sample command is:
sampleApp.exe  -aboutdialog

If the application instance is already is running, if the command is given gain,then one more app instance will be launched and closed after process.
So is it related to any priority?.

Instead of Postmessage() if i create the object of the dialog every time it is coming to foreground in command line  also.
But the second insatnce of app is running upto when i close the dialog.so we have used postmessage.

So which one is better or is there any other thing  i have to modify
Please share if any ideas..

Why WPF Designer not in VC++ 2013?

$
0
0
I like to use ribbon UI control in VC++ project which already exists and started redesigning it.But WPF designer is available for C# and VB, but not for VC++ in Visual studio 2013 pro. So is there any easy and straight solution to use WPF UI design in Managed VC++ ?


VS2012 Tracker.exe can't find midl.exe

$
0
0

Hi,

I've got a dynamic library project with an idl file and compile is failing with the following error

TRACKER : error TRK0005: Failed to locate: "midl.exe". The system cannot find the file specified.

I up the logging to diagnostic and noticed in the command line that it is not specifying the proper location for midl.exe.

C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\Tracker.exe /d C:\Windows\Microsoft.NET\Framework\v4.0.30319\FileTracker.dll /c midl.exe

I compared it to a separate project that works and that command line looks like the below, which leads me to believe this is project file related.

C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\Tracker.exe /d C:\Windows\Microsoft.NET\Framework\v4.0.30319\FileTracker.dll /c "C:\Program Files (x86)\Windows Kits\8.0\bin\x86\midl.exe"

What are some possible causes of the path of midl.exe being modified?

Thanks.

vc++ 6.0 code migration in to VC++ (VS2010) not compile. typedef not work properly

$
0
0

template<class _Ty, class _A = std::allocator<_Ty> >

class ABCVector {
public:
 typedef ABCVector<_Ty, _A> _Myt;
 typedef _A allocator_type;
 typedef _A::size_type size_type;
 typedef _A::difference_type difference_type;
 typedef _A::pointer _Tptr;
 typedef _A::const_pointer _Ctptr;
 typedef _A::reference reference;
 typedef _A::const_reference const_reference;
 typedef _A::value_type value_type;
 
 typedef std::reverse_iterator<const_iterator, value_type, const_reference, _Ctptr, difference_type> const_reverse_iterator;
 typedef std::reverse_iterator<iterator, value_type, reference, _Tptr, difference_type> reverse_iterator;
};

Error Lisr

Error 4 error C2146: syntax error : missing ';' before identifier 'size_type'
Error 5 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error 7 error C2146: syntax error : missing ';' before identifier 'difference_type'
Error 8 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error 10 error C2146: syntax error : missing ';' before identifier '_Tptr'
Error 11 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error 13 error C2146: syntax error : missing ';' before identifier '_Ctptr'
Error 14 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error 16 error C2146: syntax error : missing ';' before identifier 'reference'
Error 17 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error 19 error C2146: syntax error : missing ';' before identifier 'const_reference'
Error 20 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error 22 error C2146: syntax error : missing ';' before identifier 'value_type'
Error 23 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error 24 error C2065: 'const_iterator' : undeclared identifier
Error 25 error C2065: '_Ctptr' : undeclared identifier
Error 26 error C2065: 'iterator' : undeclared identifier
Error 27 error C2065: '_Tptr' : undeclared identifier

How to Display multiple images in same Window using win32api and c++

$
0
0
I successfully Displayed Images in a Viewer Window following this procedure
Steps in Displaying a bitmap--   0. Get a DC with  BeginPaint()    1. Create a memory device context with CreateCompatibleDC()   2. Loaded bitmap with CreateCompatibleBitmap()]   3. Select bitmap into the memory DC using SelectObject()   4. Copy bitmap from memory DC to device DC using StretchBit()



I need to display images as a list as thumbnails in a single window(named Thumbnail Window).how to do this using Win32API and c++(not to use MFC)
First I splitted my Application window into two as First as Thumbnail window and Viewer Window..
I did this using CreateWindowEx()..Now i Need to display thumbnails of images in thumbnail window when i open a folder containing images.
On clicking on first thumbnail image from Thumbnail window i need to view it in Viewer Window then Next images and viewing it in Viewer window.

How to do this using only in Win32API and C++.
It would be a great help if someone helps
Thanks




Getting error 'operator !=' is ambiguous in VS2010

$
0
0

Hi,

I have a old C++ project which is building successfully with vs2008, but when i migrate it to VS2010 it is giving below error

C:\Program Files\Microsoft Visual Studio 10.0\VC\include\vector(609): error C2593: 'operator !=' is ambiguous
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\xmemory(268): could be 'bool std::operator !=<_Ty,_Ty>(const std::allocator<_Ty> &,const std::allocator<_Ty> &) throw()'
1>          with
1>          [
1>              _Ty=USER_AREA_RIGHTS
1>          ]
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\utility(417): or       'bool std::rel_ops::operator !=<std::allocator<_Ty>>(const std::allocator<_Ty> &,const std::allocator<_Ty>&)' [found using argument-dependent lookup]
1>          with
1>          [
1>              _Ty=USER_AREA_RIGHTS
1>          ]
1>          while trying to match the argument list '(std::allocator<_Ty>, std::allocator<_Ty>)'
1>          with
1>          [
1>              _Ty=USER_AREA_RIGHTS
1>          ]
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\vector(606) : while compiling class template member function 'void std::vector<_Ty>::_Assign_rv(std::vector<_Ty> &&)'
1>          with
1>          [
1>              _Ty=USER_AREA_RIGHTS
1>          ]
1>          OPCServer.cpp(2161) : see reference to class template instantiation 'std::vector<_Ty>' being compiled
1>          with
1>          [
1>              _Ty=USER_AREA_RIGHTS
1>          ]

below is the code

struct USER_AREA_RIGHTS {

WCHAR szArea[PDS_PROCESS_AREA_NAME_LEN];
DWORDdwAccessRights;
};

typedef vector< USER_AREA_RIGHTS > USER_AREAS_RIGHTS_VEC;
typedef map< wstring, USER_AREAS_RIGHTS_VEC, less<wstring> > USER_DOMAIN_RIGHTS_MAP;

USER_AREA_RIGHTS UserRights;

for (DWORD n = 0; n < dwCnt;n++) {

memset(&UserRights,0,sizeof(USER_AREA_RIGHTS));

UserRights.dwAccessRights = *(pAccessMasks + n);
wcsncpy(UserRights.szArea,CharUpperW(*(pAreas + n)),
min(sizeof(UserRights.szArea)/2,wcslen(*(pAreas + n))));

UserRightsVec.push_back(UserRights);


CoTaskMemFree(*(pAreas + n));
}

m_UserRightsMapNew.insert(pair<wstring,USER_AREAS_RIGHTS_VEC >(CharUpperW((LPWSTR)(*it).c_str()),UserRightsVec));

if i comment below line it is building successfully.

m_UserRightsMapNew.insert(pair<wstring,USER_AREAS_RIGHTS_VEC >(CharUpperW((LPWSTR)(*it).c_str()),UserRightsVec));

Viewing all 15302 articles
Browse latest View live


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