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

64bit manifest problem / side by side issue

$
0
0
Hi all,

I have a 64bit app that refuses to start, it complains about common controls supposedly amiss (in the event log. the error message popping up when starting the app is something completely useless, of course. "...aplication configuration is incorrect....").

It's built from the same source tree than the corresponding 32bit app, which uses some common controls functionality, however, it used to work and now it suddenly doesn't any more.

Anyone have any hints on how i can systematically go about finding out where the problem is? I told VS2005 explicitly to not include or generate any manifests, and yet i end up with a bloody manifest file after linkage. I wonder whether that suddenly got embedded as well and now is wreaking havoc.

Any hints greatly appreciated.

- Balt

VS2015 C++ Project fails to build the second time using /DEBUG:fastlink

$
0
0

    After cleaning the solution and performing a full build with /DEBUG:fastlink, I can run and debug fine.  If I modify a source file (actually, I don't even modify it, just save it so it rebuilds), I get the linker error...

SeverityCode DescriptionProjectFileLineSourceSuppression State
ErrorC1052 program database file, 'G:\iTunes2015\BuildResults\Debug64\bin\iTunesCore.pdb', was generated by the linker with /DEBUG:fastlink; compiler cannot update such PDB files; please delete it or use /Fd to specify a different PDB filenameiTunesCoreG:\iTunes2015\iTunes\Application\Search\SearchPreviewViewController.cpp9Build

This is reproducible.  I am using MSVC 2015 Update 3.  I cannot reproduce this in a simpler project to submit to Microsoft.  I can, however, provide build logs if it helps diagnose/fix the issue.  For this configuration, I have incremental linking enabled.

How can I use fastlink in a way that does not generate this error?

Thanks,

Phil

Get COM port number in Visual C++

$
0
0
Hi,

For my application I have to be able to read the COM port number and use it in the program. I have a USB device connected to the computer which is virtually mapped to a serial port. The USB device isn't always assigned the same COM port number, of course. This depends on the computer. So, I need a function to read the COM port number and start the serial port reading afterwards. The following code snippet connects to the serial port and starts a thread using the specified SerialEventManager.
So, I need a function before the if (com!=0) statement that returns me the com_port of my USB device (e.g. COM6). Device Instance ID/Hardware ID is known. It should also be possible to read COM port values higher than COM9. There were some problems posted in the forum with port numbers higher than 9.

Code Snippet

char com_port[6];

int            erreur;
Tserial_event *com;
com = new Tserial_event();


getcom(com_port,DeviceID);


if (com!=0)
{
            com->setManager(SerialEventManager);
            erreur = com->connect(com_port, 4800, SERIAL_PARITY_NONE, 8, false);


            if (!erreur)
            {
                do
                {
                    com->setRxSize(5);

//Here I do some sending and receiving over a TCP connection

                   
                }
                while(true);
            }
            else
            {
                printf("ERROR : com->connect (%ld)\n",erreur);
                printf("Could not connect to serial port! Exiting...\n");
            }   
}


So how would this function look like?
void getcom(char *var_comport, DeviceID)

CPP not reading from library after initializing.

$
0
0

Hi all,

So I am trying to setup the OpenCv Library, but the compiler fails to read things from the library. I have added the bin path to my system settings and added the library details to my project properties, yet there is still a red line under the library in the code.

I tried restarting the computer couple of times but I still get the C1083 error. I need to fix this issue asap.

Thanks in advance :)


Is there any source code available for PsExec tool (sysinternals) ?

$
0
0

I am wondering, how the PsExec tool from Sysinternals authenticating and executing programs in remote machines.

Can anyone provide the source code for PsExec ?

Can somebody tell me the steps/logics to authenticate and start applications in remote machine?

problems migrating macro definitions from VS2008 to VS2015

$
0
0

I recently upgraded from VS2008 to VS2015, after some difficulty, tried to open a VS2008 project (10+ years old) and got a lot of mysterious error reports about macros being used before defined. Is there a way I can recreate my project from surviving .cpp. .rc and .h files?

I still have my 2008 install on my laptop but I don't want to mess with it before I know what the problem is.

I really don't think I need VS2015 anyway. I do very little development, and simply keep up with my project files to fix ongoing bugs.

Please help!

Is there anyone who can look at my project and recommend a fix?

The worst is, I had a HD crash on my backup drive, where I do daily backups, so I cannot simply go back 2 days to a state where things worked.

If I cannot retrieve this project it is at least 15 years down the drain!

Help!

DllMain question, the DLL_THREAD_ATTACH is not used

$
0
0

I'm trying to understand how the DLL_THREAD_ATTACH works.

I think DLL_THREAD_ATTACH is used when the LoadLibrary is executed in a thread. But it always runs under DLL_PROCESS_ATTACH. Why?

Here is my code

#include<stdio.h>
#include<windows.h>


int  AccessSharedResource(LPVOID parameter);
int main()
{
	DWORD lpThreadId;
	HANDLE hThread[1];
	hThread[0]=CreateThread(
			NULL,//secuirty flag
			0,//default stack size
			(LPTHREAD_START_ROUTINE)AccessSharedResource,
			NULL,//the parameter passed to function AccessSharedResource
			0,//start the function (AccessSharedResource) immediately
			&lpThreadId // thread Identifier
	);
	WaitForMultipleObjects(1,hThread,true,INFINITE);
	return 0;
}

int  AccessSharedResource(LPVOID parameter)
{
	printf("start to run LoadLibrary...\n");
	HMODULE m=LoadLibrary("runTimeDllMain.dll");
	FreeLibrary(m);//Explicity unload the runTimeDllMain.dll


	return 0;
}

runTimeDllMain.dll

extern "C" __declspec(dllexport) int Add(int a)
{
	a++;
	return ++a;
}

//liweiNote:DllMain is case senstitve
bool WINAPI DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                     )
{
  //  test = "loaded"; //You also change on this location the value of a variable
    switch (ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH:
       printf("DLL MAIN DLL_PROCESS_ATTACH\n");
        break;
    case DLL_THREAD_ATTACH:
      printf("DLL_THREAD_ATTACH\n");
        break;
    case DLL_THREAD_DETACH:
      printf("DLL_THREAD_DETACH\n");
        break;
    case DLL_PROCESS_DETACH:
     printf("DLL_PROCESS_DETACH\n");
        break;
    }
    return TRUE;
}

Weird case Help API with non local resources.

$
0
0
Hi!. 
I've been using the Help API and I found an interesting situation that I don't know how to deal with:
There are some pages that do not reside locally in the help catalog but that can be accessed using an internet connection in a transparent way. In the MS HelpViewer there is a warning shown when you access a non locally existent resource:

You are viewing online content. The topic is not available on your computer, but it is available in one or more books. Select a book to download.

I was wondering how can I get the internet html for those non locally existent topics. In the next two lines of code you can how I'm trying in C++ to do so. The first one works because the topic with id "d21f75bc-1a93-4cb9-8b9b-6fa0e81886bf" exists locally but the second one does not exist locally (it is the VerifyScript Function)

IUnknownPtr content = helpRead->GetIndexedTopic(helpCatalog, "d21f75bc-1a93-4cb9-8b9b-6fa0e81886bf", NULL); // Exists locally

IUnknownPtr content2 = helpRead->GetIndexedTopic(helpCatalog, "4780aa9f-6df0-4901-8de4-3f9118320e1b", NULL); // Non existent locally


How can I know the Internet URL to access the resource. There must be a way since the MS HelpViewer is doing it. 

Thank you very much for your time.

blocking sockets

$
0
0

I am not sure if this is the appropriate forum for this question. I am new to UDP communication. I am working on a client server C++ app that communicates between a Windows and Linux environment using UDP. Windows is the client. The client and server are able to send/receive packets but later both the server and client recvfrom() calls block. I did some investigation and modified the receive call using select call before receiving like below to read data only when data  is available. Below is the client call and the server code is similar. I guess in this case there is data available for reading but the call blocks.

int result = 0;

fd_set  readfds; do { FD_ZERO ( &read_flags ); FD_SET ( socket, &read_flags ); result = select ( socket + 1, &read_flags, NULL, NULL, NULL ); } while ( result == -1 && errno == EINTR ); if( result > 0 ) { if(FD_ISSET( socket,&read_flags )) {

nbytes = recvfrom ( socket, buff, bufflen, 0, (struct sockaddr*)&si_other, &slen ); } }


But even with this modification the recvfrom() call does not return sometimes and blocks. It is also noted that since the select call does not return sometimes, the recvfrom() call is not invoked. I also tried by setting a time out for select but that doesn't solve the issue.

What could be the reason behind this?

Also what is the equivalent of  fcntl() linux call and constants like  O_NONBLOCK and F_GETFL in Windows?





visual studio

$
0
0

''SeverityCodeDescriptionProjectFileLineSuppression State
Error (active)cannot open source file "vcruntime.h"ConsoleApplication1c:\Program Files\Windows Kits\10\Include\10.0.10240.0\ucrt\corecrt.h10''

this error comes always. i've recently installed visual studio professional. and it even doesnot recognize prinf and scanf satements for c++.


_sntscanf_s doesnt work as expected in VS2015

$
0
0

try this

const int TEXT_BUFFER_SIZE = 400;
TCHAR szBuffer[TEXT_BUFFER_SIZE];

szBuffer[0] = '0';
szBuffer[1] = '\0';
szBuffer[2] = '2';
szBuffer[3] = '3';
szBuffer[4] = '\0';
szBuffer[5] = '\0';

double d;
_sntscanf_s(szBuffer,_countof(szBuffer), _T("%lf"), &d);

I would expect d to be 0 but in VS2015 it will return 23.

Shadow stack in vectorcall calling convention

$
0
0

Hi,

According to vectorcall calling convention a shadow space should be allocated for vector types and HVAs on 64 bit architecture.

For each vector type or HVA aggreagte, 8 byte should be allocated.

Is the allocated shadow space in addition to the already allocated 32 byte? Will it reside before or after other arguments on the stack?


Thanks,

Oren

GIF and LZW

$
0
0

Hi

I want to read GIF images (decoder) but i have problem on LZW decompressing. I do not know any thing about it. Is there a library like zlib for LZW?

I do not want understand LZW how to work? I only need a simple code to decompress and compress bytes!

But if you can explain it easily with byte to byte example of a GIF file I wish to implement it.

VS 2010 - error LNK1123: failure during conversion to COFF: file invalid or corrupt

$
0
0

I wish it would tell me what's corrupt.

any tips?

Is there any API to open a windows10 modern calendar in vc++ win32?

$
0
0

Hi,

Is there any API to open the modern calendar from a C++ Application.

Please help me in finding an API to open (HxCalendarAppImm.exe) executable from a C++ application.

Thanks for the Help!!


Regards, Ravi Raj Nukala


Bluetooth Authentication Failure: BluetoothAuthenticateDeviceEx() returns ERROR_INVALID_PARAMETER

$
0
0

In the following code I'm using BluetoothAuthenticateDeviceEx() to initiate authentication with a remote Bluetooth device.  "int callbacklock = 0;" and "BLUETOOTH_DEVICE_INFO  btdi = { 0 };" are globals defined elsewhere in the code.  The remote device is set up to do Just Works mode (Bluetooth classic mode only and no pass keys) with COD 000000 for testing purposes.

Code is built using Visual Studio 2015 Professional and MS SDK 8.1 on a Win7 64bit machine.  Target platform is defined as x86. This is a Windows console application.

When this code is run, BluetoothAuthenticateDeviceEx() returns ERROR_INVALID_PARAMETER.  Code never passes "while (callbacklock);" since the callback BluetoothAuthCallback() is never called by the running code (verified by no output of fprintf() within the callback).  The BluetoothRegisterForAuthenticationEx() function works fine with return code ERROR_SUCCESS.  If I remove "while (callbacklock);", connect() call is made and a pop up "A bluetooth device is trying to connect" is displayed on the bottom right corner of the desktop.  If I click on it, bluetooth device is installed and the connect() succeeds.  If I don't click the pop up, connect() fails.  In our application we don't want any user interaction to receive or click a pop up (or install a remote bluetooth device).  That's why BluetoothAuthenticateDeviceEx() is used with a callback to handle any request programmatically.  As the description to BluetoothAuthenticateDeviceEx() indicates on MS web, the ERROR_INVALID_PARAMETER means a problem with btdi. However, I don't see a problem with btdi.  I even printed out btdi.Address.ullLong value before and after BluetoothAuthenticateDeviceEx() and it has correct address of the remote device. Please let me know why BluetoothAuthenticateDeviceEx() fails in code below.

// Authentication callback
BOOL WINAPI BluetoothAuthCallback(LPVOID pvParam, PBLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS pAuthCallbackParams)
{
    DWORD dwRet;

    fprintf(stderr, "BluetoothAuthCallback 0x%x\n", pAuthCallbackParams->deviceInfo.Address.ullLong);
    BLUETOOTH_AUTHENTICATE_RESPONSE AuthRes;
    AuthRes.authMethod = pAuthCallbackParams->authenticationMethod;
    fprintf(stderr, "Authmethod %d\n", AuthRes.authMethod);
    // Check to make sure we are using numeric comparison (Just Works)
    if (AuthRes.authMethod == BLUETOOTH_AUTHENTICATION_METHOD_NUMERIC_COMPARISON)
    {
        fprintf(stderr, "Numeric Comparison supported\n");
    }
    AuthRes.bthAddressRemote = pAuthCallbackParams->deviceInfo.Address;
    AuthRes.negativeResponse = FALSE;

    // Commented out code is used for pairing using the BLUETOOTH_AUTHENTICATION_METHOD_PASSKEY method
    //memcpy_s(AuthRes.pinInfo.pin, sizeof(AuthRes.pinInfo.pin), L"1234", 0);
    //AuthRes.pinInfo.pinLength = 0;
    // Respond with numerical value for Just Works pairing
    AuthRes.numericCompInfo.NumericValue = 1;

    // Send authentication response to authenticate device
    dwRet = BluetoothSendAuthenticationResponseEx(NULL, &AuthRes);
    if (dwRet != ERROR_SUCCESS)
    {
        fprintf(stderr, "BluetoothSendAuthenticationResponseEx ret %d\n", dwRet);
        if (dwRet == ERROR_CANCELLED)
        {
            fprintf(stderr, "Bluetooth device denied passkey response or communicatino problem.\n");
        }
        else if (dwRet == E_FAIL)
        {
            fprintf(stderr, "Device returned a failure code during authentication.\n");
        }
        else if (dwRet == 1244)
        {
            fprintf(stderr, "Not authenticated\n");
        }
    }
    else
    {
        fprintf(stderr, "BluetoothAuthCallback finish\n");
    }

	callbacklock = 0;

    return 1; // This value is ignored
}

bool Bluetooth_Connect() { ULONG ulRetCode; WSADATA WSAData = {0}; SOCKADDR_BTH RemoteBthAddr = {0}; INT iResult = BT_SUCCESS; BOOL bContinueLookup = FALSE, bRemoteDeviceFound = FALSE; ULONG ulFlags = 0, ulPQSSize = sizeof(WSAQUERYSET); HANDLE hLookup = NULL; PWSAQUERYSET pWSAQuerySet = NULL; // Initialize WinSock. ulRetCode = WSAStartup(MAKEWORD(2, 2), &WSAData); pWSAQuerySet = (PWSAQUERYSET) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ulPQSSize); if ( NULL == pWSAQuerySet ) { iResult = STATUS_NO_MEMORY; wprintf(L"!ERROR! | Unable to allocate memory for WSAQUERYSET\n"); return false; } // // Search for the device with the correct name // if ( iResult == BT_SUCCESS ) { for ( INT iRetryCount = 0; !bRemoteDeviceFound && (iRetryCount < BT_MAX_INQUIRY_RETRY);iRetryCount++ ) { // // WSALookupService is used for both service search and device inquiry // LUP_CONTAINERS is the flag which signals that we're doing a device inquiry. // ulFlags = LUP_CONTAINERS; // // Friendly device name (if available) will be returned in lpszServiceInstanceName // ulFlags |= LUP_RETURN_NAME; // // BTH_ADDR will be returned in lpcsaBuffer member of WSAQUERYSET // ulFlags |= LUP_RETURN_ADDR; if ( 0 == iRetryCount ) { // wprintf(L"*INFO* | Inquiring device from cache...\n"); wprintf(L"*INFO* | Searching for device with Bluetooth...\n"); } else { // // Flush the device cache for all inquiries, except for the first inquiry // // By setting LUP_FLUSHCACHE flag, we're asking the lookup service to do // a fresh lookup instead of pulling the information from device cache. // ulFlags |= LUP_FLUSHCACHE; // // Pause for some time before all the inquiries after the first inquiry // // Remote Name requests will arrive after device inquiry has // completed. Without a window to receive IN_RANGE notifications, // we don't have a direct mechanism to determine when remote // name requests have completed. // wprintf(L"*INFO* | Unable to find device. Waiting for %d seconds before re-inquiry...\n", BT_DELAY_NEXT_INQUIRY); Sleep(BT_DELAY_NEXT_INQUIRY * 1000); wprintf(L"*INFO* | Inquiring device ...\n"); } // // Start the lookup service // iResult = BT_SUCCESS; hLookup = 0; bContinueLookup = FALSE; ZeroMemory(pWSAQuerySet, ulPQSSize); pWSAQuerySet->dwNameSpace = NS_BTH; pWSAQuerySet->dwSize = sizeof(WSAQUERYSET); iResult = WSALookupServiceBegin(pWSAQuerySet, ulFlags, &hLookup); // // Even if we have an error, we want to continue until we // reach the CXN_MAX_INQUIRY_RETRY // if ( (NO_ERROR == iResult) && (NULL != hLookup) ) { bContinueLookup = TRUE; } else if ( 0 < iRetryCount ) { wprintf(L"=CRITICAL= | WSALookupServiceBegin() failed with error code %d, WSAGetLastError = %d\n", iResult, WSAGetLastError()); break; } while ( bContinueLookup ) { // // Get information about next bluetooth device // // Note you may pass the same WSAQUERYSET from LookupBegin // as long as you don't need to modify any of the pointer // members of the structure, etc. // //ZeroMemory(pWSAQuerySet, ulPQSSize); //pWSAQuerySet->dwNameSpace = NS_BTH; //pWSAQuerySet->dwSize = sizeof(WSAQUERYSET); if ( NO_ERROR == WSALookupServiceNext(hLookup, ulFlags,&ulPQSSize, pWSAQuerySet) ) { // // Compare the name to see if this is the device we are looking for. // if ( ( pWSAQuerySet->lpszServiceInstanceName != NULL ) && ( ( BT_SUCCESS == _strnicmp(pWSAQuerySet->lpszServiceInstanceName, "Test1",5)) || (BT_SUCCESS == _strnicmp(pWSAQuerySet->lpszServiceInstanceName, "Test2",5)) ) ) { // // // // Found a remote bluetooth device with matching name. // // Get the address of the device and exit the lookup. // // CopyMemory(&RemoteBthAddr, (PSOCKADDR_BTH) pWSAQuerySet->lpcsaBuffer->RemoteAddr.lpSockaddr, sizeof(RemoteBthAddr)); bRemoteDeviceFound = TRUE; bContinueLookup = FALSE; } } else { iResult = WSAGetLastError(); if ( WSA_E_NO_MORE == iResult ) { //No more data // // No more devices found. Exit the lookup. // bContinueLookup = FALSE; } else if ( WSAEFAULT == iResult ) { // // The buffer for QUERYSET was insufficient. // In such case 3rd parameter "ulPQSSize" of function "WSALookupServiceNext()" receives // the required size. So we can use this parameter to reallocate memory for QUERYSET. // HeapFree(GetProcessHeap(), 0, pWSAQuerySet); pWSAQuerySet = (PWSAQUERYSET) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ulPQSSize); if ( NULL == pWSAQuerySet ) { wprintf(L"!ERROR! | Unable to allocate memory for WSAQERYSET\n"); iResult = STATUS_NO_MEMORY; bContinueLookup = FALSE; } } else { wprintf(L"=CRITICAL= | WSALookupServiceNext() failed with error code %d\n", iResult); bContinueLookup = FALSE; } } } // // End the lookup service // WSALookupServiceEnd(hLookup); if ( STATUS_NO_MEMORY == iResult ) { break; } } } if ( NULL != pWSAQuerySet ) { HeapFree(GetProcessHeap(), 0, pWSAQuerySet); pWSAQuerySet = NULL; } if ( !bRemoteDeviceFound ) { iResult = BT_ERROR; WSACleanup(); return false; } RemoteBthAddr.addressFamily = AF_BTH; RemoteBthAddr.serviceClassId = RFCOMM_PROTOCOL_UUID; //RemoteBthAddr.serviceClassId = SerialPortServiceClass_UUID; //RemoteBthAddr.port = BT_PORT_ANY; RemoteBthAddr.port = 0; HBLUETOOTH_AUTHENTICATION_REGISTRATION hRegHandle = 0; DWORD dwRet; // setup device info btdi.dwSize = sizeof(BLUETOOTH_DEVICE_INFO); btdi.Address.ullLong = RemoteBthAddr.btAddr; btdi.ulClassofDevice = 0; btdi.fConnected = FALSE; btdi.fRemembered = FALSE; btdi.fAuthenticated = FALSE; fprintf(stderr, "\nAddress print1: %llx\n", btdi.Address.ullLong); // register authentication callback. this prevents UI from showing up. dwRet = BluetoothRegisterForAuthenticationEx(&btdi, &hRegHandle, &BluetoothAuthCallback, NULL); if (dwRet != ERROR_SUCCESS) { fprintf(stderr, "BluetoothRegisterForAuthenticationEx ret %d\n", dwRet); ExitProcess(2); } fprintf(stderr, "\nAddress print2: %llx\n", btdi.Address.ullLong); // authenticate device (will call authentication callback) AUTHENTICATION_REQUIREMENTS authreqs = MITMProtectionNotRequired; fprintf(stderr, "BluetoothAuthReqs = %d\n", authreqs);

callbacklock = 1;

dwRet = BluetoothAuthenticateDeviceEx(NULL, NULL, &btdi, NULL, authreqs); fprintf(stderr, "\nAddress print3: %llx\n", btdi.Address.ullLong); if (dwRet != ERROR_SUCCESS) { fprintf(stderr, "BluetoothAuthenticateDevice ret %d\n", dwRet); if (dwRet == ERROR_CANCELLED) { fprintf(stderr, "Cancelled"); } else if (dwRet == ERROR_INVALID_PARAMETER) { fprintf(stderr, "Invalid Parameter"); } else if (dwRet == ERROR_NO_MORE_ITEMS) { fprintf(stderr, "Already paired!"); } } fprintf(stderr, "Pairing finished\n"); while (callbacklock); // // Open a bluetooth socket using RFCOMM protocol // BtSocket = socket(AF_BTH, SOCK_STREAM, BTHPROTO_RFCOMM); if ( INVALID_SOCKET == BtSocket ) { wprintf(L"=CRITICAL= | socket() call failed. WSAGetLastError = [%d]\n", WSAGetLastError()); ulRetCode = ERROR; WSACleanup(); return false; } // Set timeout on socket int iOptVal = 25; int iOptLen = sizeof (int); iOptVal = 8192; setsockopt(BtSocket,SOL_SOCKET,SO_RCVBUF,(char *) &iOptVal,iOptLen); // getsockopt(BtSocket,SOL_SOCKET,SO_RCVBUF,(char *) &iOptVal,&iOptLen); iOptVal = 10; setsockopt(BtSocket,SOL_SOCKET,SO_RCVTIMEO,(char *) &iOptVal,iOptLen); // setsockopt(BtSocket,SOL_SOCKET,SO_SNDTIMEO,(char *) &iOptVal,iOptLen); //ULONG bAuthenticate = FALSE; //setsockopt(BtSocket,SOL_SOCKET,SO_BTH_AUTHENTICATE,(char *) &bAuthenticate,sizeof(ULONG)); // // Connect the socket (pSocket) to a given remote socket represented by address (pServerAddr) // if ( SOCKET_ERROR == connect(BtSocket, (struct sockaddr *) &RemoteBthAddr, sizeof(SOCKADDR_BTH)) ) { wprintf(L"=CRITICAL= | connect() call failed. WSAGetLastError=[%d]\n", WSAGetLastError()); ulRetCode = ERROR; WSACleanup(); return false; } Sleep(100); char rcv_buf[16]; int x,n; // flush the buffer x=0; while (x != -1) { x = recv(BtSocket, (char *)rcv_buf, (int)sizeof(rcv_buf), 0); } return true; }


In MFC how to assign same bitmaps to toolbar and menu from resource editor?

$
0
0

Hi,

In MFC SDI,I assigned same resource id for toolbar buttons and menu items.the toolbar button is loaded with bitmaps but the bitmaps are not getting displayed for menu items.

thanks.




Upgrading from VS2010 to VS2013 has killed my MFC/ActiveX control styles

$
0
0

My application is a .NET app (WPF and WinForms) which calls C++ projects via ActiveX. We use a mixture of C++, vC++ and MFC

Recently we upgraded from VS2010 to VS2013.

We have 3 projects which uses MFC dialogs. Since upgrading to VS2013 pack 5 (with Multi Byte support) we've noticed that every project with MFC dialogs renders them without any styles

In each project's stdafx.h file, we have (note, no ifdef surrounding)

#pragma

comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")

If I open the Property Pages for Linker -> Manifest File, I can see that Allow Isloation is set to true.

If I add a new MFC project to the solution and debug that project directly, visual styles are rendered as expected :s

What else can I do to try to fix this? 



Step by Step Tutorial for Creating a PHP Extension

$
0
0

Is it possible share a Step by Step Tutorial for Creating a PHP Extension (php_xxx.DLL) for use at Client Side on VC++ 2012?  I want to be able to read and write to Serial port from PHP page.

Please also advise if the php extension will have backward compatibility for older versions of PHP. For example, I create php extension using vc11 for PHP 5.6.19, can it be used with say PHP 5.4.6?

PlayEnhMetaFile and ERROR_INVALID_FUNCTION

$
0
0

In my application, I call PlayEnhMetaFile() inside a WM_NOTIFY handler and it works fine. 

A code snippet from the WM_NOTIFY handler is:
        if (((LPNMHDR)lParam) -> idFrom == (MY_BUTTON)){
            LPNMCUSTOMDRAW lpnmCD = (LPNMCUSTOMDRAW)lParam;
            //Call PlayEnhMetaFile() here with the DC value as lpnmCD->hdc

But when PlayEnhMetaFile is called inside a DLL function, it returns 0 and GetLastError() returns ERROR_INVALID_FUNCTION. The DLL exports a function to receive a HDC (lpnmCD->hdc is passed in), and some other parameters, including a rect value of lpnmCD->rc. Although the function is getting called correctly, we get the errors I mentioned, and the image does not display. Not sure what's going wrong when the DLL implementation. There is nothing very different inside the DLL function, just what we're doing outside the DLL is placed in a function in the DLL.

Appreciate any help on this.

TIA.

Viewing all 15302 articles
Browse latest View live