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

VS2015 - MFC140.dll deactivates my Activation Context due to ISOLATION AWARE - how to fix?

$
0
0

using Visual Studio 2015, I have a MMC Snapin that is expected to use the Common Controls Version 6. In order to achieve it, I created XML Manifests and attached it to my Snapin.DLL. Type 24 (RT_MANIFEST), ID 2 (or 3). 

I am able to create V6 Windows Controls such as Buttons myself using the Win32 API with ISOLATION_AWARE 1, a manifest in RT_MANIFEST/2 and no own activation context switching. 

I am also able to create V6 Windows Controls such as Buttons myself using the Win32 API with no ISOLATION_AWARE, activating my own activation context from RT_MANIFEST/3 using ActivateActCtx . 

But as soon as I use MFC classes to instanciate controls, MFC selects the wrong activation context for me and all i get is a V5 Control. 

This code snippet creates two buttons as seen above on ONE dialog, and the first one is V6 Common Control, and the second one is V5 Common Control

    HWND hwndButton = ::CreateWindow("BUTTON","direct button",
        WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
        10,10,100,100,m_hWnd,NULL,(HINSTANCE)GetWindowLong(m_hWnd, GWL_HINSTANCE),NULL);   

    CButton *testButton = new CButton(); 
    testButton->Create("MFC Button", WS_CHILD | WS_VISIBLE, CRect(10, 120, 200, 220),this, 12345);

This happens regardless of ISOLATION_AWARE defined for my application or not, and regardless of the Resource ID (2 or 3) used for the RT_MANIFEST.

It seems that MFC140.dll was compiled with ISOLATION_AWARE and tries to identify the correct activation context to use. According to the debugger it goes through winbase.inl, Function WinbaseIsolationAwarePrivatetRgzlnPgpgk(...), where it boils down to 

if (!IsolationAwareQueryActCtxW(
        QUERY_ACTCTX_FLAG_ACTCTX_IS_ADDRESS
        | QUERY_ACTCTX_FLAG_NO_ADDREF,
        &WinbaseIsolationAwarePrivateT_UnPgpgk,
        NULL,
        ActivationContextBasicInformation,
        &actCtxBasicInfo,
        sizeof(actCtxBasicInfo),
        NULL))
        goto Exit;

Which queries the activation context for an address inside the mfc140.dll.  I believe the code is expected to be inline in my own application (as written in a comment, and as tests showed, if it is, it works ok), but inside mfc140 it queries the wrong component for an activation context.

It gets one, but i don't know from where, since the MFC140.dll does not have one in its resources. The activation context it gets selects the v5 common controls. 

I cannot use RT_MANIFEST(24)/ resource ID 1, which might work, since i am in an DLL. 

So my Questions are:

- how do i disable the activation context management in MFC140.dll? OR

- how do i provide the correct activation context to MFC?


wlanapi.dll / native WIFI | HostedNetwork | multiple physical WLAN network adapters

$
0
0

Hello,

using the Microsoft Windows Software Development Kit v7.0 (SDK), i compiled the WirelessHostedNetwork Example. I use the Native Wifi Functions in wlanapi.dll.

As in the wireless Hosted Network Example described, I open a "WlanOpenHandle", initialize with "WlanHostedNetworkInitSettings", set the SSID name "SetConnectionSettings" and the password with "SetSecondaryKey".

With "WirelessHostednetworkStartUsing" and "WlanHostedNetworkStopUsing" i can Start / Stop the Virtual AcessPoint. In the Network and Sharing Center there is allways a "Microsoft Virtual WiFi Miniport Adapter" created.

However, we have the scenario that the computer has more then only one physical WLAN network adapter installed. Therefore we want to assign a certain physical wireless network card to the WirelessHostedNetwork.

Using the "WlanEnumInterfaces" function it is possible to enumerate allphysical wireless network cards and its GUID on the computer. However, it has not possible to assign a certain wireless network card to the wlanHandle (I got after "WlanOpenHandle"). It is also required to configure the IP address range of the WirelessHostedNetwork. By default, this is set always to 192.168.173.XXX.         Thanks a lot.


Mixed programing

$
0
0

hello

i use intel compiler visual stdio(intel parallel 2015) to compile my project

console ( c source ) #include <stdio.h> #include <stdlib.h> //#include <conio.h> #include <string.h> //#define readfile readfile_ extern void readfile(char*, int*); int main() { int n, count; char Fname[9]; char Name[10]; strcpy(Fname,"AMIN.for"); fprintf( stderr, "%s\n", Fname); readfile( Fname, &n, strlen(Fname) ); fprintf( stderr, "n = %d\n", n); // fprintf( stderr, "%s\n", Name); return 0; } subroutine ( Lib fortran ) subroutine readfile( fname1, m ) character fname1*(*) integer m integer iounit,i iounit=15 write(*,*) fname1 c10 format (a9) open(iounit,file = fname1,action='read') read (iounit,*) m c20 format (i10) write(*,*) m close(iounit) return end subroutine

this is my project and i don't have a problem

in this line i have a qestion

readfile( Fname, &n, strlen(Fname) );

i want to change line 

readfile( Fname, &n );

is it possible? how to call without lenght character or how to calling convert to run and compile it correctly?

how to change setting vs2012 togettoit?

Special Thanks For Your Prompet Reply ( excuse me for bad spelling )


Fmshirdel




Friend Modifier NOT working in C++ VS 2015

$
0
0

Hi,

It appears that the friend modifier is not working in VS 2015.  The code below, a .h and a .cpp file illustrate the issue.

The .h file

#pragma once
class CClassWithFriends
{
public:
	CClassWithFriends();
	~CClassWithFriends();

	int ClassMemberGetiValue(int iIndex);

	int m_iValue2;

protected:
	int m_iValue3;

	friend int GetSum();
	friend int GetiValue(int iIndex);

private:
	int m_iValue;

};

The .cpp file

#include "stdafx.h"
#include "ClassWithFriends.h"


CClassWithFriends::CClassWithFriends()
{
	m_iValue = 0;
	m_iValue2 = 1;
	m_iValue3 = 2;
}


CClassWithFriends::~CClassWithFriends()
{
}

int CClassWithFriends::ClassMemberGetiValue(int iIndex)
{
	int iValue;

	switch (iIndex) {
	case 0:
		iValue = m_iValue;
		break;
	case 1:
		iValue = m_iValue2;
		break;
	case 2:
		iValue = m_iValue3;
		break;
	default:
		iValue = -1;
	}

	return iValue;

}

int GetiValue(int iIndex)
{
	int iValue;

	switch (iIndex) {
	case 0:
		iValue = m_iValue;
		break;
	case 1:
		iValue = m_iValue2;
		break;
	case 2:
		iValue = m_iValue3;
		break;
	default:
		iValue = -1;
	}

	return iValue;
}

int GetSum()
{
	int iSum;

	iSum = m_iValue + m_iValue2 + m_iValue3;
	return iSum;
}

I've tried putting the friend function declarations in protected, private, and public blocks.  Regardless, I get the errors listed below.

SeverityCodeDescription ProjectFileLine
ErrorC2065'm_iValue': undeclared identifierClassFriendTest \\lti-fps01.laserndt.com\users$\nshore\my documents\visual studio projects\classfriendtest\classfriendtest\classwithfriends.cpp45
ErrorC2065'm_iValue2': undeclared identifierClassFriendTest \\lti-fps01.laserndt.com\users$\nshore\my documents\visual studio projects\classfriendtest\classfriendtest\classwithfriends.cpp48
ErrorC2065'm_iValue3': undeclared identifierClassFriendTest \\lti-fps01.laserndt.com\users$\nshore\my documents\visual studio projects\classfriendtest\classfriendtest\classwithfriends.cpp51
ErrorC2065'm_iValue': undeclared identifierClassFriendTest \\lti-fps01.laserndt.com\users$\nshore\my documents\visual studio projects\classfriendtest\classfriendtest\classwithfriends.cpp64
ErrorC2065'm_iValue2': undeclared identifierClassFriendTest \\lti-fps01.laserndt.com\users$\nshore\my documents\visual studio projects\classfriendtest\classfriendtest\classwithfriends.cpp64
ErrorC2065'm_iValue3': undeclared identifierClassFriendTest \\lti-fps01.laserndt.com\users$\nshore\my documents\visual studio projects\classfriendtest\classfriendtest\classwithfriends.cpp64

Error C2065 is: "'identifier' : undeclared identifier"

Am I missing something here?

Thanks.

- Neil Shore

SetCurrentDirectoryW won't Drop to C:\ with ".." or "."

$
0
0

Hi there,

Developing an application which creates and removes folders with SetCurrentDirectoryW andRemoveDirectoryW rather well, excepting on the final deletion of the folder:

"C:\myfolder"

GetCurrentDirectoryW still flags the current directory as in "myfolder" after the SetCurrentDirectoryW (L".") or SetCurrentDirectoryW (L"..") call from there. "myfolder" was created with CreateDirectoryW

Using SetCurrentDirectoryW (L"\\\\\?\\C:\\") worked however.

Insights appreciated.

Edit: WRT the question in this post, are there any other Win APIs that can deal with the navigation of 32k path names?



A natural, B flat, C sharp, D compile






Conditional closing of a dialog using ESC key

$
0
0

MFC Dialog application.

I know this has been discussed before, but my situation is a bit different.

I have a dialog which is an editor and I allow the user to close it down using the ESC key. To do this I use PreTranslateMessage:

	if ((pMsg->message == WM_KEYDOWN || pMsg->message == WM_KEYUP ||
		pMsg->message == WM_CHAR)&& (pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE))
	{
		// Eat it.
		bNoDispatch = TRUE;
		bDealtWith = TRUE;

		if (pMsg->wParam == VK_ESCAPE)
			PostMessage(WM_CLOSE);
	}

So far, so good. It works. The problem, is when I have a popup dialog on screen. If I click ESC inside the popup dialogue, the popup closes (correctly) but the editor closes too. I don't want this.

I tried doing a test of "pMsh->hWnd == GetSafeHwnd()" in the hopes that would work but it made things worse. Nothing would close then.

What is the simplest way to allow my editor to close with ESC, and to let popup dialogs close with ESC (but not the editor with it)?

I hope I am making sense.

Thank you.

Andrew


Problem using 'If-else' block inside 'catch' block.

$
0
0

Hello all,

I have some problem using the 'if-else' statements inside the 'catch' block.

When I am executing the below code, everytime the label2 is showing the condition inside the 'if()', i.e.,

एक आम है

It is not taking the else if()'s condition even if the label1 is 'It is an apple' or else..

catch(Exception^ ex){

array<String^>^ err1;
err1 = ex->ToString();

label1->Text = err1[1];

if (err1[1] = L"There is a mango")
{
     label2->Text = L"एक आम है";
}
else if (err1[1] = L" It is an apple")
{
     label2->Text = L"यह एक सेब है";
}
else if
{
}
.
.
.
.
else if()
{
}

else
{
     label2->Text = L"कुछ भी नहीं है";
}

}

How to execute all statements depending on the err1?

Thanks,

Humaira.

Live Data Stream

$
0
0

I'm going to develop the program that recevie the xml file from the linux server using Live Data Stream.

But i fail to reciving data.

What is the Live Data Stream. and How i do for receive data. For example How should i write the code.

Thanks.


Question regarding Issue with Japanese input

$
0
0

Hi, 

I have a windows desktop app in a custom drawn window that needs to receive Japanese input in Hiragana mode. 

Normally Alt - ~ will toggle the input mode and then pop up the Japanese input text box after I type, which allows me to enter Japanese text and then hit enter to send the text to my application.

My problem is, when running my application, the Japanese text input box refuses to show when I press keys after I have used Alt - ~ to change to Hiragana mode. The input mode does change, I just don't get the input dialog.

I'm not sure what attributes my window needs to have to get this Japanese text input box to display. I suspect it is a combination of focus and other settings that decide whether windows activates this input box or not.

My question would be, from a Win32 programmers perspective, what do I need to do with my window to get windows to trigger the Japanese text input box when I am in Hiragana input mode ?

Any help would be appreciated.


visual studio 2015 not letting me download c++ developer package

$
0
0

hey guys,

so i tried opening up a visual studio c++ project i was working on from school. the first thing i saw was that the project was unloaded. i tried to reload it and then visual studio told me i need to download the c++ tools (just bought a new laptop). when i try to download the tools, i keep getting the following error code: -2147205120. below this the window says "fatal error during installation". what does this mean and how do i fix this?

C++/CLI extract punctuation marks from the text

$
0
0
Is there an easy way to separate text's punctuation marks from all the words, basically what would be left a dot with a few commas.

Issue with mfc110ud.dll

$
0
0

We are getting the following error message in our application:

"information not available, no symbols loaded for mfc110ud.dll"

It seems that the issue arise due to the fact that the dll is not loaded correctly.    
Kindly note that the same issue is not observed in the Win 2008R2 boxes. Also, there have been no code changes from our end as well. This issue seems to be present in all later versions of Windows OS like Win8, Win7 etc

Any method that is called in this dll is being returned as NULL - such as GetDlgItem. 

What has changed? Please let us know.

Thanks,

Vishal

[WRL] IRadioStatics.GetRadiosAsync() fails in x86: 80040154 Class not registered

$
0
0

I use next code in C++ to retrieve the radio devices on the system using WRL

	RoInitializeWrapper initialize(RO_INIT_MULTITHREADED);
	ComPtr<IRadioStatics> radioFactory;
	HStringReference classId(L"Windows.Devices.Radios.Radio");
	HRESULT hres = RoGetActivationFactory(classId.Get(), __uuidof(IRadioStatics), &radioFactory);
	ComPtr<IAsyncOperation<__FIVectorView_1_Windows__CDevices__CRadios__CRadio*>> asyncOperation;
	hres = radioFactory->GetRadiosAsync(&asyncOperation);
	asyncOperation->put_Completed
	(
		Callback<IAsyncOperationCompletedHandler< __FIVectorView_1_Windows__CDevices__CRadios__CRadio* >>
		(
			[](IAsyncOperation<__FIVectorView_1_Windows__CDevices__CRadios__CRadio* >* pHandler, AsyncStatus status)
			{
				// check status and use the stream here
				return S_OK;
			}
		).Get()
	);
	ComPtr<__FIVectorView_1_Windows__CDevices__CRadios__CRadio> radios;
	hres = asyncOperation->GetResults(&radios);
	unsigned int num;
	radios->get_Size(&num);
	wprintf_s(L"Radio devices found: %u\n", num);

It works fine when compiled for x64 and returns my bluetooth radio device found.

But in x86 this code causes next debug errors:

net\mobility\radiomanagement\winrt\lib\radiomanager.cpp(56)\Windows.Devices.Radios.dll!0FDCD3CD: (caller: 0FDCF3A6) ReturnHr[PreRelease](1) tid(cf0) 80040154 Class not registered
net\mobility\radiomanagement\winrt\lib\radiomanager.cpp(39)\Windows.Devices.Radios.dll!0FDCD2FE: (caller: 0FDCBD22) ReturnHr[PreRelease](2) tid(cf0) 80040154 Class not registered
net\mobility\radiomanagement\winrt\lib\radioimpl.cpp(34)\Windows.Devices.Radios.dll!0FDCBCBD: (caller: 0FDD5F9E) ReturnHr[PreRelease](3) tid(cf0) 80040154 Class not registered
net\mobility\radiomanagement\winrt\lib\utils.cpp(158)\Windows.Devices.Radios.dll!0FDD5AF3: (caller: 0FDD1A83) ReturnHr[PreRelease](4) tid(cf0) 80040154 Class not registered
net\mobility\radiomanagement\winrt\lib\radiostaticsprivateserver.cpp(62)\Windows.Devices.Radios.dll!0FDD1A98: (caller: 0FDC9CCF) LogHr(1) tid(cf0) 80040154 Class not registered

... and any device is returned.

Any help will be appreciated.

Thanks.


Problem to line

$
0
0
Hi,
How to resolve these

Error	1	error C2374: 'str' : redefinition; multiple initialization	c:\app2\act2.cpp	94	1	DBServer
Error	2	error C2088: '<<' : illegal for class	c:\app2\act2.cpp	96	1	DBServer


due to these?
			strftime(buffer, 80, "%d-%m-%Y %I:%M:%S", &timeinfo);
94			std::string str(buffer);
			//std::cout << str;
96			t00 << "2 " << str;



Many Thanks & Best Regards, Hua Min

Windows 10: CreateFile() for a named pipe returns ERROR_PIPE_BUSY always

$
0
0

Hi,

I'm working on a legacy application which has been working successfully for years on Windows 7, but fails in some cases on Windows 10. 

One such case is use of named pipes. A client application trying to access a named pipe using CreateFile() always returns the error ERROR_PIPE_BUSY, and goes into an infinite loop since we try to do WaitNamedPipe() intermittently, similar to https://msdn.microsoft.com/en-us/library/windows/desktop/aa365592(v=vs.85).aspx

I've checked the code, and found that CloseHandle() is being called correctly. Any clues why this should fail consistently on Windows 10?

TIA.


Display error code number through exception handling

$
0
0

Hello all,

I made connection to database via VC++ windows form application. I tried running small queries through it.

In catch block, I wrote the below line of code:

catch(Exception^ex)
{
MessageBox::Show(ex->Message);
}

I am able to display the error in a pop-up window. Ex: "No database selected"

Now, I need to show the relevant error code number also. Like  "Error Code: 1046. No database selected"

Is there any possibility to show error number?

Thanks,

Humaira

 

Where to download the MFC CUBE OpenGL in SDI sample?

$
0
0

Where to download the MFC CUBE OpenGL in SDI sample?

I can find plenty of pages which refer to it, but it seems impossible to actually find the code, from within VS2013 samples help or on the MSDN site.

Does anyone know of a direct link to the sources?


http://www.ransen.com Cad and Graphics software

No text in CMD window when i start any simple app.

$
0
0

I am started coding in Visual Studio 2015, and i use CLR console app. I write simple program... build it, and when I run it the CMD appears but no text is displayed??? Anyone knows how to solve this?

include"stdafx.h"

#include<iostream>

usingnamespacestd;

voidmain() {

inta, b;

cout <<"Unesite a?";

cin >>a;

cout <<"Unesite b?";

cin >>b;

cout <<"Zbroj a i b je "<<a+ b <<endl;

 

 

}

How does Windows Server 2012 load visual studio 2005 built dlls?

$
0
0

Hi,

My application and the depency dlls were all built using Visual Studio 2005. And every thing works fine on Windows 7 and Windows Server 2008 but not on Windows Server 2012.

I'm seeing an issue in my application because of the order the dlls are getting loaded.

For ex:

MyApp depends on DllA,DllB.

DllA depends on DllC and DllD.

In Windows 7 the dlls are getting loaded in the following order...

MyApp,DllA,DllC,DllD and DllB.

In Windows Server 2012 the dlls are getting loaded in the following order...

MyApp,DllA,DllB,DllC and DllD.

Everything compiles and runs fine in Windows Server 2012 but some functions are failing due to the dll load order.

This is causing the issue in my application on Windows Server 2012 as we are doing the things based on the order the dlls are getting loaded in Windows 7. Since the order is different in Windows Server 2012 it is failing to do some initializations.

So my question is there any switch in Visual Studio 2005/2010 that we can force the dependencies to load first?

Or is this how Windows Server 2012 loads the dlls?

Thanks 



Smart pointers -- parent / child relationships

$
0
0

I was experimenting with smart pointers in the context of Parent / Child relationship classes. Unless I have missed something, I believe that I have reached a point where I must either mix raw and smart pointers or abandon smart pointers. Below is a very simplified conceptual outline of what I would like to do:

#include <memory>

using namespace std ;


class Parent ;

class Child
{
	public :
		Child ( weak_ptr<Parent> Parent ) { mParent = Parent ; }
	private :
		weak_ptr<Parent> mParent ;
} ;


class Parent : public enable_shared_from_this<Parent>
{
	public :
		Parent () ;
	private :
		// Not a unique_ptr, because in real life application other things will
		// need to point to the child as well.
		shared_ptr <Child> mChild ;
} ;

Parent::Parent()
{
	// ***Conceptually**** what I want to do, but this will fail of course.
	mChild = new Child( shared_from_this() ;
}

Each Child belongs to one Parent, and the Child needs to know the Parent to which it belongs. The construction of the Parent logically includes the construction of the Child. I use a weak_ptr in the Child to reference the Parent to avoid keeping the Parent alive longer than it should because of a shared_ptr in the Child. (To complicate matters even more the outside world needs access to both Parent and Child instances, the intention was to use smart pointers to do this.)

The problem is that I cannot use "shared_from_this()" in the Parent constructor to pass a smart pointer to the created Child. (shared_from_this() does not work in object constructors). So my questions are:

1) Have I missed something that would enable me to do the kind of thing I am trying to do?

2) Is there a tidy way to use smart pointers in this sort of situation. (I know that I could defer the construction of the Child until after the construction of the Parent, possibly using a factory model for creating the Parent object. In my case that would not be a tidy way, as in fact I will be deriving many different classes from my Parent. I do not want a factory for each different derived class.)

3) Given the above, and that classes accessing the Parent / Child instances will do so via shared_ptr, is this a case where smart pointers and raw pointers must be mixed (the raw pointers being the Child reference to the Parent).

Any advice is gratefully accepted.

Andrew.



Viewing all 15302 articles
Browse latest View live


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