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

While embedding COM DLL manifest getting "Manifest authoring error C1010001"

$
0
0

I'm getting a weird error while adding one specific COM DLL manifest file into project:

Manifest authoring error C1010001: Values of attribute "tlbid" not equal in different manifest snippets.

Whereas adding another manifest doesn't cause this while building the project. In fact there are already many manifests added in project.

Did anyone face such error? What could be the reason behind it!

Please suggest.

Thanks in advance.

-upx86




How to resolve memory leakage for CMFCTabCtrl :AddTab

$
0
0

Hi,

The scenario is as follows:

I have the following code snippet in OnCreate() of my class:

CMFCTabCtrl m_TabsWnd;

// Create Tab
    // Create tabs window:
    if (!m_TabsWnd.Create(CMFCTabCtrl::STYLE_FLAT, rect_dummy, this, 5))
    {
        TRACE0("Failed to create output tab window\n");
        return -1;      // fail to create
    }

CDockablePane mp_Tab1;

DWORD no_close_bar_style = AFX_DEFAULT_DOCKING_PANE_STYLE & ~AFX_CBRS_CLOSE & ~AFX_CBRS_FLOAT;   

/*Creating pane*/

if(!mp_Tab1->Create(_T("Tab 1"), &m_TabsWnd, CRect(0, 0, 200, 200), TRUE,12345, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,AFX_CBRS_REGULAR_TABS, no_close_bar_style ))
    {
        TRACE0("Failed to create Pane\n");
        return FALSE; // failed to create
    }    

   
    m_TabsWnd.AddTab(mp_Tab1,_T("Tab 1"), (UINT)2,TRUE); //utceoppane.cpp (608) line:

I have the following code snippet in destructor of my class():

m_TabsWnd.RemoveAllTabs()

After running visual leak detector:

Leak Hash: 0xEB2A82CF, Count: 1, Total 72 bytes
  Call Stack (TID 10512):
    0x7744E0C6 (File and line number not available): ntdll.dll!RtlAllocateHeap

    f:\dd\vctools\crt_bld\self_x86\crt\src\dbgheap.c (160): sample.exe!_malloc_dbg + 0x1B bytes
    f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxmem.cpp (379): sample.exe!operator new + 0x15 bytes
    f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxmem.cpp (80): sample.exe!CObject::operator new + 0x16 bytes
    f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxbasetabctrl.cpp (304): sample.exe!CMFCBaseTabCtrl::InsertTab + 0x11 bytes
    f:\dd\vctools\vc7libs\ship\atlmfc\src\mfc\afxbasetabctrl.cpp (254): sample.exe!CMFCBaseTabCtrl::AddTab
    f:\workingarea\sourcecodes\release_versions\ver3_2_22\sample\utceoppane.cpp (608): sample.exe!CUtcEopPane::OnCreate + 0x33 bytes

So after calling RemoveAllTabs() also visual leak detector is showing hash leak pointing to the line  m_TabsWnd.AddTab(mp_Tab1,_T("Tab 1"), (UINT)2,TRUE).

Please help me in order to solve the same.

Thanks & Regards,

Shweta B

Need a help for oplock request and oplock break using VC++ code

$
0
0

I am using following function to request oplock but how should I know that I acquired oplock properly??

void GetOplock()
{
HANDLE FileHandle;
REQUEST_OPLOCK_OUTPUT_BUFFER Response;
BOOL bSuccess = FALSE;
BOOL ResultValid = TRUE;
DWORD PartialCheckSum = 0;
DWORD BytesSummedCounter = 0;
HANDLE KeyEvents[2];
OVERLAPPED ReadOverLapped;
LARGE_INTEGER Offset = { 0 };
DWORD RetVal;


//
// Open the file for Asynchronous I/O
//

FileHandle = CreateFile(FilePath,
GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
NULL);

if (INVALID_HANDLE_VALUE == FileHandle) {
_tprintf(_T("Error 0x%x Opening %s\n"), GetLastError(), FilePath);
return;
}


ResetEvent(OplockInfo->OverLapped.hEvent);

bSuccess = DeviceIoControl(FileHandle,
FSCTL_REQUEST_OPLOCK,
&OplockInfo->Request,
sizeof(OplockInfo->Request),
&Response,
sizeof(Response),
NULL,
&OplockInfo->OverLapped);


if (bSuccess == FALSE && ERROR_IO_PENDING == GetLastError()) 
{
_tprintf(_T("got op"));
return;
}

if (bSuccess || (ERROR_IO_PENDING != GetLastError())) 
{
_tprintf(_T("We failed to acquire the oplock, the error code was 0x%x\n"), GetLastError());
CloseHandle(FileHandle);
return;
}
}

I am also using wireshark to check oplock state but not getting oplock state

It is humble request that please give me the proper suggestion to request oplock at user level.

plz provide sample code if possible.

 

How to rotate bitmap/png file to draw transparent color correct by using CImage?

$
0
0

Hi All,

     I encounter a problem that for function CImage::PlgBlt could not draw the transparent color correct for rotation, it will draw transparent color with black color, the expected result is that it should ignore the transparent color.

     The following code is  to draw bitmap, the view background color is white color, and as you know the bitmap has white color as transparent color, so the code will look like:

Case 1: Correct result picture to draw bitmap by calling CImage::TransparentBlt or

CImage::Draw, we see inside bitmap border it will have transparent color, it will

ignore these pixel an not draw them.

Case 2: Wrong result picture to draw bitmap in rotation by calling CImage::PlgBlt,

here we see, it will draw transparent color with black, the is not correct, it should also

ignore it and keep it the same as background color.

So how to solve the problem that when using CImage::PlgBlt to draw transparent color

correct(ignore or not draw the pixel)?

Any suggestion is welcome.

Best regards,

Michael


create 3 tabbed group document of equal size

$
0
0

Hi,

I would like to create some MDI tabbed group documents and I would like equal size for each one.

unfortunately creating a tabbed group divide actve gorup in 2 equal gorups, so if I create 3 groups by code I've got one of them occupying 50% of size and 2 others ones 25% each

is there a solution to equilibrate size for all groups.

thanks

Yan

MFC Desktop application with "advanced" touch / pen support

$
0
0

Hello

I have the followed Problem. I have a MFC Desktop application running under Windows 10 and I'd like to improve the touch / pen capabilities.

Windows 10 itself and also i.e. the file Explorer Supports in a good way the touch / pen capailities. When I touch the Screen and keep the finger on the Screen a surrounding square is displayed. If the square is displayed I know if I remove the finger a context menu will be displayed.

The same with the pen capabilities. I Keep the pen on the Screen, the Little circle will Close, if I than remove the pen the context menu is displayed.

I am assuming this is a General Windows functionality. I tried RegisterTouchWindow, but the square for touch and the circle for pen events does not Show up. Is there a Special API to have this Feature or what am I missing? Most Microsot Desktop applications have this Feature. Also Notepad Supports this.

My question is how can I implement the above described Feature?


Best regards

Bordon

Note: Posted code pieces may not have a good programming style and may not perfect. It is also possible that they do not work in all situations. Code pieces are only indended to explain something particualar.



how to tell if a dialog initializes

$
0
0

Hi, I am trying to add some actions after a dialog initializes, below is the code, but it crashes coz it implements before it initializes, how can I do this after

TopBar *m_bannerTop; void CMainFrame::topBarSizeChange()

{ if(IsWindow(m_bannerTop->m_hWnd)) { m_bannerTop->SetWindowPos(NULL, rect_win.left - nBorderWidth, rect_win.top- nTitleBarHeight - nBorderWidth, nBorderWidth, nTitleBarHeight, SWP_FRAMECHANGED|SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_SHOWWINDOW|SWP_NOOWNERZORDER); } }


Help finding "Microsoft Visual C++ 2015 Redistributable Update 2" download

$
0
0

Hi,

I am trying to figure out how to support customers who are not "Microsoft patching" their systems.
The product we distribute is developed with VS2015 update 2.
It ranges from W7 to W10, servers and workstations.

I have read "Introducing the Universal CRT"

and I see the following downloads:

Visual C++ Redistributable for Visual Studio 2015

Microsoft Visual C++ 2015 Redistributable Update 3

Can someone please point me to: Microsoft Visual C++ 2015 Redistributable Update 2?

Thank you in advance.

Tony


Anthony LaMark


[C\C++] - how get arrow keys(correctly) using getch()?

$
0
0

if(by ascii table):

  • 37(left arrow)
  • 38(up arrow)
  • 39(right arrow)
  • 40(down arrow)

why i can't get right results from getch() function?

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>



int main()
{
	unsigned char a;
	while(1)
	{
		system("cls");
		a=getch();

		if (a==27)
			break;
		else if (a==37)
			printf("LEFT");
		else if (a==80)
			printf("DOWN");
		else
			printf("%d",(int) a);


	}
	return 0;
}

because sometimes i get 224 value.. strange

Hi-Tech , this appears to be way over my learning curve.

$
0
0

I am only a beginner at this type stuff . so I think I should stick to only the basics.

Visual Studio 2015 Community - Create new project window keeps popping up

$
0
0

I am trying to create a new C++ console application project in visual studio 2015 community, After setting a project name, when i click OK button, the new project window of visual studio disappears and then pops up again. It keeps disappearing and popping again every time i click OK button.

This problem only arises when i try to create a C++ project. I am able to create C# or pythonwithout any problem.

How can i fix this problem ?

PS. I only encountered this problem recently. Before that, i was able to create a C++ project without any problem.


swap or creating a temp in sorting

$
0
0
void SelectionSort(int &b, vector<int> &vec3)//first = max or min, compare it with all the rest of the elements
{
	for (int x = 0; x < b; x++)
	{

		for(int y=(1+x); y<b; y++)
		{
			if(vec3[x]>vec3[y])
				swap(vec3[x], vec3[y]);
		}
	}

}

void selectionSort(int list[], int length)
{
int index;
int smallestIndex;
int location;
int temp;

for (index = 0; index < length - 1; index++)
{

smallestIndex = index;

for (location = index + 1; location < length; location++)
if (list[location] < list[smallestIndex])
smallestIndex = location;

temp = list[smallestIndex];
list[smallestIndex] = list[index];
list[index] = temp;
}
}
from the information above, the first one use swap function each time while the other one creating a temp and change the value only at the end. are there any advantage and disadvantage of each method?

Upgrade Visual C++ 6.0 to Visual Studio 2015

$
0
0

I have an MFC application that I built with Visual C++ 6.0 and I'd like to upgrade it to Visual Studio 2015.

I have tried to open .dsw file using Visual Studio 2015.

It asked me for conversion at the time of opening. I was proceed with conversion option.

After successful conversion I tried to build same, but give me error with error no C1083. Cannot open include file ‘stdafx.h’.

I checked in project files the header file was present there.

Is there any additional setting other than include file path and library path ?

High DPI with checkboxes and radio butttons

$
0
0

I have a large MFC application that I have made High DPI aware.  I have all my windows and dialogs scaling based on the dpi of the monitor they are being displayed.  The windows 10 anniversary update helped with things like non client scaling, but I have some big issues with checkboxes and radio buttons.  The fonts on these controls have been scaled correctly. but the glyphs for the square or circle are either too large or too small.  If the main display is at 250% (4k) and another display is at 100% the checkbox square is WAY too big on the other display on both windows and dialogs.  If the main and other display scale factor is switched, then the checkbox square is too small.

Is there something I can do in my application or is this glyph drawing totally an issue with Windows itself or is it an issue that needs to be solved by Microsoft?

Reference articles used:

https://msdn.microsoft.com/en-us/library/windows/desktop/dn469266(v=vs.85).aspx

https://blogs.technet.microsoft.com/askcore/2015/12/08/display-scaling-in-windows-10/

https://blogs.windows.com/buildingapps/2016/10/24/high-dpi-scaling-improvements-for-desktop-applications-and-mixed-mode-dpi-scaling-in-the-windows-10-anniversary-update/#Hra3ASt46fOszMRg.97

Thanks

Incremental linking broken with WHOLEARCHIVE

$
0
0

Hi,

I am using the /WHOLEARCHIVE option when linking a static lib, however with this option changes made to the static lib aren't linked into the final executable unless I rebuild the whole solution. The equivalent option with the GCC toolchain (--whole-archive) works as expected.

John Chapman.


C++ free Code Analysis Tools

$
0
0
Looking for free C++ tools for performing analyzing metrics, static code analysis and also Dynamic Analysis Tool.

saikalyan

NaN < NaN? Visual Studio 2015 breaking change or bug?

$
0
0

Visual Studio 2013 (Update 5) and Visual Studio 2015 (Update 3) can't seem to agree on whether or not NaN < NaN.

Is this a compiler bug?  I'm under the impression that comparisons involving NaN are defined to be false.

#include <limits>
#include <cassert>

static const double n = std::numeric_limits<double>::quiet_NaN();

int main()
{
	assert( !(n < n) );
}


Why the line "this->root = new Node(item);" returns to "main" function but doesn't continue to execute the line "this->count = 1;"

$
0
0

Node.h

#ifndef NODE
#define NODE
#include <iostream>
using namespace std;
template<typename type>
class Node
{
	template<typename type> friend class Tree;
	template<typename type> friend ostream& operator<<(ostream&, const Node&);
	template<typename type> friend ostream& operator<<(ostream&, Node*);
	private:
		type item;
		Node<type>* left;
		Node<type>* right;
	public:
		Node(const type&, Node<type>* = NULL, Node<type>* = NULL);
		type GetItem();
		void SetItem(type);
		type& Item();
		Node<type>* GetLeft();
		void SetLeft(Node<type>*);
		Node<type>*& Left();
		Node<type>* GetRight();
		void SetRight(Node<type>*);
		Node<type>*& Right();
		~Node();
};
template<typename type>
ostream& operator<<(ostream&, const Node<type>&);
template<typename type>
ostream& operator<<(ostream&, Node<type>*);
#endif

Node.cpp

#include "Node.h"
template<typename type>
Node<type>::Node<type>(const type& itm, Node<type>* left, Node<type>* right) : item(itm), left(left), right(right) {};
template<typename type>
type Node<type>::GetItem() { return this->item; }
template<typename type>
void Node<type>::SetItem(type new_item) { this->value = new_item }
template<typename type>
type& Node<type>::Item() { return this->item; }
template<typename type>
Node<type>* Node<type>::GetLeft() { return this->left; }
template<typename type>
void Node<type>::SetLeft(Node<type>* new_left) { this->left = new_left; }
template<typename type>
Node<type>*& Node<type>::Left() { return this->left; }
template<typename type>
Node<type>* Node<type>::GetRight() { return this->right; }
template<typename type>
void Node<type>::SetRight(Node<type>* new_right) { this->right = new_right; }
template<typename type>
Node<type>*& Node<type>::Right() { return this->right; }
template<typename type>
Node<type>::~Node()
{
	if (this->left != NULL)
		delete this->left;
	if (this->right != NULL)
		delete this->right;
	cout << "Node " << this->item << " destroyed" << endl;
}
template<typename type>
ostream& operator<<(ostream& o, Node<type>* n)
{
	if (n == NULL)
		return o;
	return o << n->left << n->item << ' ' << n->right;
}
template<typename type>
ostream& operator<<(ostream& o, const Node<type>& n) { return o << n.left << n.item << ' ' << n.right; }

Tree.h

#ifndef TREE
#define TREE
#include "Node.cpp"
template<typename type>
class Tree
{
	template<typename type> friend ostream& operator<<(ostream&, const Tree&);
	template<typename type> friend ostream& operator<<(ostream&, Tree*);
	private:
		Node<type>* root;
		unsigned count;
	public:
		Tree();
		void insert(const type&);
		bool exists(const type&);
		unsigned size();
		~Tree();
};
template<typename type>
ostream& operator<<(ostream&, const Tree<type>&);
template<typename type>
ostream& operator<<(ostream&, Tree<type>*);
#endif

Tree.cpp

#include "Tree.h"
template<typename type>
Tree<type>::Tree() : root(NULL), count(0) {}
template<typename type>
void Tree<type>::insert(const type& item)
{
	if (this->root != NULL)
	{
		Node<type>* pointer = this->root;
		for (;;)
			if (item > pointer->item)
			{
				if (pointer->right != NULL)
					pointer = pointer->right;
				else
				{
					pointer->right = new Node<type>(item);
					this->count++;
					return;
				}
			}
			else
			{
				if (pointer->left != NULL)
					pointer = pointer->left;
				else
				{
					pointer->left = new Node<type>(item);
					this->count++;
					return;
				}
			}
	}
	else
	{
		this->root = new Node<type>(item); //returns to "main" function. Why!?
		this->count = 1; //Doesn't continue to execute or carrying out this line. Why!?
	}
}
template<typename type>
bool Tree<type>::exists(const type& item)
{
	Node<type>* pointer = this->root;
	while (pointer != NULL)
	{
		if (pointer->item == item)
			return true;
		if (item > pointer->item)
			pointer = pointer->right;
		else
			pointer = pointer->left;
	}
	return false;
}
template<typename type>
unsigned Tree<type>::size() { return this->count; }
template<typename type>
Tree<type>::~Tree<type>()
{
	if (this->root != NULL)
		delete this->root;
	cout << "Tree destroyed" << endl;
}
template<typename type>
ostream& operator<<(ostream& o, const Tree<type>& t) { return o << t.root; }
template<typename type>
ostream& operator<<(ostream& o, Tree<type>* t) { if (t != NULL) return o << t->root; return o; }

main.cpp

#include "Tree.cpp"
void error_template_class_tree_exists_not_working_properly()
{
	cout << endl << "member function \"exists\" of template class \"Tree\" doesn't work properly!";
	cout << endl << "Press <Enter> key to quit" << endl;
	cin.get();
}
void main()
{
	{
		Tree<int> tree_of_integers;
		if (tree_of_integers.exists(10))
			cout << "The integer 10 exists in the tree of integers" << endl;
		else
			cout << "The integer 10 does NOT exist in the tree of integers" << endl;
		cout << "In tree of integers there are " << tree_of_integers.size() << " integers" << endl;
		cout << tree_of_integers.size() << " integers in the tree!? This tree is empty! So let's insert some integers ... and then ";
		tree_of_integers.insert(8);
		tree_of_integers.insert(3);
		tree_of_integers.insert(10);
		tree_of_integers.insert(1);
		tree_of_integers.insert(6);
		tree_of_integers.insert(14);
		tree_of_integers.insert(4);
		tree_of_integers.insert(7);
		tree_of_integers.insert(13);
		cout << "here is a list of all integers in tree of integers now in ascending order:" << endl << endl << tree_of_integers << endl << endl;
		cout << "Now we can see in the list " << tree_of_integers.size() << " integers." << endl;
		if (tree_of_integers.exists(10))
			cout << "Now the integer 10 is in the list, ";
		else
		{
			error_template_class_tree_exists_not_working_properly();
			return;
		}
		if (tree_of_integers.exists(5))
		{
			error_template_class_tree_exists_not_working_properly();
			return;
		}
		else
			cout << "but the integer 5 is NOT in the list." << endl;
	}
	{
		Tree<double> tree_of_doubles;
		if (tree_of_doubles.exists(17.591))
			cout << "The number 17.591 exists in the tree of real numbers" << endl;
		else
			cout << "The number 17.591 does NOT exist in the tree of real numbers" << endl;
		cout << "In tree of real numbers there are " <<  tree_of_doubles.size() << " numbers" << endl;
		cout << tree_of_doubles.size() << " numbers in the tree!? This tree is empty! So let's insert some real numbers ... and then ";
		tree_of_doubles.insert(17.591);
		tree_of_doubles.insert(1.625);
		tree_of_doubles.insert(12.932);
		tree_of_doubles.insert(0.5);
		tree_of_doubles.insert(1234.5);
		tree_of_doubles.insert(1342365.1427);
		tree_of_doubles.insert(23.4567);
		tree_of_doubles.insert(0.25);
		tree_of_doubles.insert(0.718239);
		tree_of_doubles.insert(45.6);
		cout << "here is a list of all integers in tree of real numbers now in ascending order:" << endl << endl << tree_of_doubles << endl << endl;
		cout << "Now we can see in the list " << tree_of_doubles.size() << " real numbers." << endl;
		if (tree_of_doubles.exists(17.591))
			cout << "Now the real number 17.591 is in the list, ";
		else
		{
			error_template_class_tree_exists_not_working_properly();
			return;
		}
		if (tree_of_doubles.exists(24.321))
		{
			error_template_class_tree_exists_not_working_properly();
			return;
		}
		else
			cout << "but the real number 24.321 is NOT in the list." << endl;
	}
	cout << "Thanks for watching!" << endl << endl << "Press <Enter> to quit" << endl;
	cin.get();
}

_sntprintf behavior changed in VS 2015 from VS 2010

$
0
0

Hi, 

The value of result in below piece of code used to be 9 in Visual studio 2010 but now it's returning -1 in visual studio 2015. 

 

#define tsizeof(x) (sizeof(x) / sizeof(x[0]))      // number of elements in array

TCHAR abc[10] = TEXT("");
    int result;
    result = _sntprintf(abc, tsizeof(abc)-1, TEXT("%s%s"), TEXT("123456789"), TEXT("") );

This is just the customized part of issue. When our product recently ported to VS2015, this piece of code is not working. The last parameter is actually a variable which could be empty or non-empty. So the issue is seen when it's empty. Could you please help


Ashwin


SW_HIDE doesn't work with ShellExecute on windows 8 and IE10

$
0
0
Hi,
 
SW_HIDE doesn't work with ShellExecute on windows 8 and Internet Explorer 10. Does any one has any clue on the same.
 
I tried the below code.
 
HINSTANCE hInstance = ShellExecute(NULL, _T("open"),_T("IExplore.exe"), _T("www.google.com"), CString(szTemp), SW_HIDE);
 
Any help is appreciated
Viewing all 15302 articles
Browse latest View live


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