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

Rotate in PictureBox

$
0
0

Hi all

I have a problem to find intersection point in between the red line and the black vertical line.

Its not a problem before rotation, as you can see the horisontal line rotates with the red object.

what confuse me is that the coordinates of points in the array<PointF>^drawing = gcnew array<PointF>(360);

seems be rotated as well even if array is cleard

 Pen^ red = gcnew Pen(Color::Red);
		Pen^ blue = gcnew Pen(Color::Blue);
		Pen^ black = gcnew Pen(Color::Black);
		Bitmap^ DrawImage = gcnew Bitmap(Pbox1->Width, Pbox1->Height);
		Graphics^ g = e->Graphics;
		double dx = Pbox1->Width / 2.0;double dy = Pbox1->Height / 2.0;
		g->TranslateTransform(dx, dy);
		int size = drawing->Length;
		inval = false;
		g->DrawLines(red, drawing);
PointF one = PointF(drawing[270].X, drawing[270].Y);
		PointF two = PointF(drawing[90].X, drawing[90].Y);
		g->DrawLine(black, one, two);
		PointF three = PointF(0, 0);
		PointF four = PointF(0, -100);
		g->DrawLine(blue, three, four);
		Pbox1->Refresh();
		delete red, blue, black;
		Array::Clear(drawing,0, 359);
		Array::Clear(circle, 0, 359);

all help appreciated

regards ollp



can't uninstall / fix of Visual C++ 2017 and 2015

$
0
0

I can't reinstall Visual C++ 2017 and when I try to uninstall I get the following message:

Windows cannot find C:/ProgramData/Package Cache/{80586c77- db42-44bb-bfc8-7aebbb220c00}/VCredist_x86.exe. Make sure you typed the name correctly, then try again.

Where did my computer find all the DLLs named in rasman.dll, in the last two weeks?

$
0
0

Windows 8.1 on an HP Envy m6-n010dx

Can anyone tell me where my computer could have found all these DLLs in the last two weeks?

api-ms-win-core-delayload-l1-1-1, api-ms-win-core-errorhandling-l1-1-1.dll, api-ms-win-core-handle-l1-1-0.dll, api-ms-win-core-heap-l1-2-0.dll, api-ms-win-core-heap-obsolete-l1-1-0.dll, api-ms-win-core-kernel32-legacy-l1-1-1.dll, api-ms-win-core-libraryloader-l1-2-0.dll, api-ms-win-core-processenvironment-l1-2-0.dll, api-ms-win-core-processthreads-l1-1-2.dll, api-ms-win-core-profile-l1-1-0.dll, api-ms-win-core-psapi-obsolete-l1-1-0.dll, api-ms-win-core-registry-l1-1-0.dll, api-ms-win-core-string-l1-1-0.dll, api-ms-win-core-string-l2-1-0.dll, api-ms-win-core-string-obsolete-l1-1-0, api-ms-win-core-synch-l1-2-0.dll, api-ms-win-core-sysinfo-l1-2-1.dll, api-ms-win-security-base-l1-2-0.dll, api-ms-win-security-sddl-l1-1-0, api-ms-win-service-management-l1-1-0, api-ms-win-service-winsvc-l1-2-0

My wife and I have identical computers that we bought at the same time, in the same store. Now suddenly our VPN app on her computer is unable to create new miniports, and the event manager says that RasMan failed to start because it is unable to load one or more communication DLLs. Searching through rasman.dll with WordPad, I found those DLL names above. I found all of those dlls in my System32 folder, but none of them in hers. The only api-* dlls in her System32 folder are all api-ms-win-crt-* dlls. My System32 folder has all those, plus dozens of other api-* dlls besides those, including all the ones named in rasman.dll.

Two weeks ago I refreshed the system on my computer, updated it with Windows Update, and re-installed some Desktop apps.

Can anyone tell me where my computer could possibly have found all those dlls in the last two weeks?

GDI: CreateDIBSection/CreateDIBitmap Failed after several hours

$
0
0

Hi everyone,

I developed a deskstop app with GDI/MFC on Window 7. 

This app loads an image per 5s. It crashed after 4-5h and I got ERROR_INVALID_PARAMETER in CreateDIBSection.

Hereafter is the code :

UINT local_colors = 2;

RGBQUAD image_colormap[2];

image_colormap[0].rgbRed = image_colormap[0].rgbGreen = image_colormap[0].rgbBlue = 0;

image_colormap[1].rgbRed = image_colormap[1].rgbGreen = image_colormap[1].rgbBlue = 255;

UINT local_bmpInfo_size = sizeof(BITMAPINFO) + local_colors * sizeof(RGBQUAD);;

LPBITMAPINFO local_bmpInfo = (LPBITMAPINFO ) malloc(local_bmpInfo_size);

local_bmpInfo->bmiHeader.biSize        = sizeof(BITMAPINFOHEADER);
local_bmpInfo->bmiHeader.biBitCount    = 1;
local_bmpInfo->bmiHeader.biClrUsed     = local_colors;
local_bmpInfo->bmiHeader.biCompression = BI_RGB;
local_bmpInfo->bmiHeader.biHeight      = 320l;
local_bmpInfo->bmiHeader.biPlanes      = 1;
local_bmpInfo->bmiHeader.biWidth       = 320l;

CopyMemory(local_bmpInfo->bmiColors, image_colormap, local_colors* sizeof(RGBQUAD));

HDC local_hDC = ::GetDC(NULL);

if(local_hDC)

{

UCHAR* image_bits = NULL;

HBITMAP local_imgHandle = CreateDIBSection(local_hDC , local_bmpInfo, DIB_RGB_COLORS, (void**)&image_bits, NULL, 0l);

}

::Release(NULL,local_hDC);

Do you have any idea ?



[MFC]Change the menu prompt dynamically

$
0
0

Hi,

I know that chang the menu caption dynamicallly using the method "ModifyMenu()".

But I don't know that change the menu prompt dynamically.

Please help me.


Offline Documentation VS 2015

$
0
0

Hi,

The offline documentation is not working any longer for me on Visual Studio Community 2015.

Most basic win32 and DirectX functions invites me to download a book `Windows Desktop Application Development' which isn't available for download.  I have another one present: `Windows DesktopApp Development'

Browsing from the index leads to garbled section, in which I cannot click:

I had updated this issue which  appears identical, but haven't got any reply from MS, and I can't find how to request assistance (the paid service leads to an unavailable page.)

So I'm trying my luck reopening a discussion

Thanks for the help!

GDI+ problem with clipping using regions.

$
0
0

Hi

I've got code, which should do drawing clipping using regions. Regarding setting region code is very simple and typical taken from examples. Problem is when trying to draw clipped graphics, e.g. paths. When used simple syntax, like:

graphics.DrawPath(pen, path);

everything works, my drawing is clipped as should be. But trying to use more complicated method, like GraphicsPathIterator, then drawing is not visible, (is clipped completely)? e.g:

Gdiplus::GraphicsPath path;

pathIterator.Rewind();

while(0 != pathIterator.NextMarker(&path)) {
    graphics.DrawPath(pen, &path);
When not clipped code using path iterators draws fine.

Message sending macros for common controls

$
0
0

A number of the common controls (Tree View and List View in particular) have nice macros for sending various messages.

Does anyone know if similar macros exist (either officially or from a 3rd party) for the updown control, trackbar control, progress bar control, comboboxex control or tooltip control? (or why only some common controls got such message sending macros for that matter)

I am thinking of writing such macros myself (particularly for the updown control and trackbar control) but I would rather not reinvent the wheel if what I want exists somewhere already...


Why my program enter OnInitialUpdate but do not enter OnCreate

$
0
0

  My project is based on MFC.

  I have a derived class derived from CScrollView.I set breakpoints at the class's constructor ,OnInitialUpdate  and OnCreate .

  I find it enters OnInitialUpdate after entering the constructor ,but does not enter OnCreate.

  Is not every CWnd should call the OnCreate after its constructor ? 

  Looking forward for your replying.

  Best wishes to you.

Unable to send data over socket , but was able to save it in a file.

$
0
0

 Hi,

    I want to send a icon over the socket and create the bitmap on the receiver side. I have the below implementation where I'm able to save the icon locally. Could you please add your thoughts to send them over the sockets or the way through which I can receive  and create a icon on the receiver side.

Note:- I don't want to save in the file. I want to store in a buffer and send the buffer over the socket and create a icon on the other side. 

I tried the other way Link. It didn't work with some icons. So, I came back to this approach.

Thank you in advance.

Code Snippet:-

      int  nColorBits = 32;
HDC dc;
BOOL bSaved = TRUE;
dc =::GetDC(NULL); // ensure that DC is released when function ends

// Open file for writing:
HRESULT hr;
// Write header:
UCHAR icoHeader[6] = {0, 0, 1, 0, 1, 0}; // ICO file with 1 image
DWORD written =0;
CURSORINFO ci;
ci.cbSize = sizeof(ci);
GetCursorInfo(&ci);
ICONINFO iconInfo;
GetIconInfo(ci.hCursor, &iconInfo);
BITMAPINFO bmInfo = {0};
bmInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmInfo.bmiHeader.biBitCount = 0;    // don't get the color table     
if (!GetDIBits(dc, iconInfo.hbmColor, 0, 0, NULL, &bmInfo, DIB_RGB_COLORS))
{
bSaved = FALSE;
}

// Allocate size of bitmap info header plus space for color table:
int nBmInfoSize = sizeof(BITMAPINFOHEADER);
if (nColorBits < 24)
{
nBmInfoSize += sizeof(RGBQUAD) * (int)(1 << nColorBits);
}

CAutoVectorPtr<UCHAR> bitmapInfo;
bitmapInfo.Allocate(nBmInfoSize);
BITMAPINFO* pBmInfo = (BITMAPINFO*)(UCHAR*)bitmapInfo;
memcpy(pBmInfo, &bmInfo, sizeof(BITMAPINFOHEADER));

// Get bitmap data:
if((bmInfo.bmiHeader.biSizeImage != 0))
{
bSaved = FALSE;
}
CAutoVectorPtr<UCHAR> bits;
bits.Allocate(bmInfo.bmiHeader.biSizeImage);
pBmInfo->bmiHeader.biBitCount = nColorBits;
pBmInfo->bmiHeader.biCompression = BI_RGB;
if (!GetDIBits(dc, iconInfo.hbmColor, 0, bmInfo.bmiHeader.biHeight, (UCHAR*)bits, pBmInfo, DIB_RGB_COLORS))
{
bSaved = FALSE;//Testing found where we can know the image to be removed.
}

// Get mask data:
BITMAPINFO maskInfo = {0};
maskInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
maskInfo.bmiHeader.biBitCount = 0;  // don't get the color table     
if (!GetDIBits(dc, iconInfo.hbmMask, 0, 0, NULL, &maskInfo, DIB_RGB_COLORS))
{
bSaved = FALSE;
}
if(maskInfo.bmiHeader.biBitCount == 1)
{
bSaved = FALSE;
}
CAutoVectorPtr<UCHAR> maskBits;
maskBits.Allocate(maskInfo.bmiHeader.biSizeImage);
CAutoVectorPtr<UCHAR> maskInfoBytes;
maskInfoBytes.Allocate(sizeof(BITMAPINFO) + 2 * sizeof(RGBQUAD));
BITMAPINFO* pMaskInfo = (BITMAPINFO*)(UCHAR*)maskInfoBytes;
memcpy(pMaskInfo, &maskInfo, sizeof(maskInfo));
if (!GetDIBits(dc, iconInfo.hbmMask, 0, maskInfo.bmiHeader.biHeight, (UCHAR*)maskBits, pMaskInfo, DIB_RGB_COLORS))
{
bSaved = FALSE;
}
// Write directory entry:
ICONDIRENTRY dir;
dir.nWidth = (UCHAR) pBmInfo->bmiHeader.biWidth;
dir.nHeight = (UCHAR) pBmInfo->bmiHeader.biHeight;
dir.nNumColorsInPalette = (nColorBits == 4 ? 16 : 0);
dir.nReserved = 0;
dir.nNumColorPlanes = 0;
dir.nBitsPerPixel = pBmInfo->bmiHeader.biBitCount;
dir.nDataLength = pBmInfo->bmiHeader.biSizeImage + pMaskInfo->bmiHeader.biSizeImage + nBmInfoSize;
dir.nOffset = sizeof(dir) + sizeof(icoHeader);
// file.Write(&dir, sizeof(dir));

// Write DIB header (including color table):
int nBitsSize = pBmInfo->bmiHeader.biSizeImage;
pBmInfo->bmiHeader.biHeight *= 2; // because the header is for both image and mask
pBmInfo->bmiHeader.biCompression = 0;
pBmInfo->bmiHeader.biSizeImage += pMaskInfo->bmiHeader.biSizeImage; // because the header is for both image and mask

HBITMAP bmp = NULL;
BITMAPINFO info;
ZeroMemory(&info, sizeof(BITMAPINFO));
info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
info.bmiHeader.biBitCount = 32;
info.bmiHeader.biPlanes = 1;
info.bmiHeader.biCompression = BI_RGB;
info.bmiHeader.biSizeImage = pBmInfo->bmiHeader.biSizeImage;//bmpInfoHeader.biSizeImage;//sourceImage->GetArea()*4;
info.bmiHeader.biWidth = pBmInfo->bmiHeader.biWidth;//bmpInfoHeader.biWidth;
info.bmiHeader.biHeight = pBmInfo->bmiHeader.biHeight;
info.bmiHeader.biClrUsed = 0;

HANDLE hFile = CreateFile(L"E:\\abccc11.bmp", GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0);
if (!hFile) hr = HRESULT_FROM_WIN32(GetLastError());
{
bSaved = FALSE;
}
WriteFile(hFile, icoHeader,  sizeof(icoHeader), &written, 0);
WriteFile(hFile, &dir,  sizeof(dir), &written, 0); 
WriteFile(hFile, &info, nBmInfoSize, &written, 0);
WriteFile(hFile, (UCHAR*)bits, nBitsSize, &written, 0); 
WriteFile(hFile,(UCHAR*)maskBits, pMaskInfo->bmiHeader.biSizeImage, &written, 0); 

CloseHandle(hFile);

Linking errors with standard library while migrating project from VS 2005 to VS 2015 for Dll project.

$
0
0

Hello

I migrating projects from VS 2005 to VS 2015, while migrating one of the DLL project Test.dll which has a static library as input staticLib.lib.

staticLib.lib. gives multiple linking LNK 2001 & LNK 2019 errors with cpp standard library. here i am giving few below (there are many more than 100). However if I change project type from DLL to static library as Test.lib then code builds without any error.

I check on internet and then confirms that both project are build with VS 2015 using Unicode Character set and build with multi threaded debug dll as run time library. can someone please help.

LNK2001	unresolved external symbol "__declspec(dllimport) public: __thiscall std::_String_base::_String_base(void)" (__imp_??0_String_base@std@@QAE@XZ)
LNK2019	unresolved external symbol "__declspec(dllimport) struct std::_Smanip<int> __cdecl std::setw(int)" (__imp_?setw@std@@YA?AU?$_Smanip@H@1@H@Z) referenced in function "public: virtual void __thiscall XCLTlvContainer::dump(class std::basic_ostream<char,struct std::char_traits<char> > &)const " (?dump@XCLTlvContainer@@UBEXAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z)
LNK2001	unresolved external symbol "__declspec(dllimport) struct std::_Smanip<int> __cdecl std::setw(int)" (__imp_?setw@std@@YA?AU?$_Smanip@H@1@H@Z)
LNK2001	unresolved external symbol "__declspec(dllimport) public: __thiscall std::_String_base::~_String_base(void)" (__imp_??1_String_base@std@@QAE@XZ)
LNK2001	unresolved external symbol "__declspec(dllimport) public: __thiscall std::_String_base::~_String_base(void)" (__imp_??1_String_base@std@@QAE@XZ)
LNK2001	unresolved external symbol "__declspec(dllimport) public: __thiscall std::_String_base::~_String_base(void)" (__imp_??1_String_base@std@@QAE@XZ)
LNK2001	unresolved external symbol "__declspec(dllimport) public: __thiscall std::_String_base::~_String_base(void)" (__imp_??1_String_base@std@@QAE@XZ)
LNK2001	unresolved external symbol "__declspec(dllimport) public: __thiscall std::_String_base::~_String_base(void)" (__imp_??1_String_base@std@@QAE@XZ)
LNK2001	unresolved external symbol "__declspec(dllimport) public: __thiscall std::_String_base::~_String_base(void)" (__imp_??1_String_base@std@@QAE@XZ)
LNK2001	unresolved external symbol "__declspec(dllimport) public: __thiscall std::_String_base::~_String_base(void)" (__imp_??1_String_base@std@@QAE@XZ)
LNK2001	unresolved external symbol "__declspec(dllimport) public: __thiscall std::_String_base::~_String_base(void)" (__imp_??1_String_base@std@@QAE@XZ)
LNK2001	unresolved external symbol "__declspec(dllimport) public: __thiscall std::_String_base::~_String_base(void)" (__imp_??1_String_base@std@@QAE@XZ)
LNK2001	unresolved external symbol "__declspec(dllimport) public: __thiscall std::_String_base::_String_base(void)" (__imp_??0_String_base@std@@QAE@XZ)
LNK2001	unresolved external symbol "__declspec(dllimport) public: __thiscall std::_String_base::_String_base(void)" (__imp_??0_String_base@std@@QAE@XZ)
LNK2001	unresolved external symbol "__declspec(dllimport) public: __thiscall std::_String_base::_String_base(void)" (__imp_??0_String_base@std@@QAE@XZ)
LNK2001	unresolved external symbol "__declspec(dllimport) public: __thiscall std::_String_base::_String_base(void)" (__imp_??0_String_base@std@@QAE@XZ)
LNK2001	unresolved external symbol "__declspec(dllimport) public: __thiscall std::_String_base::_String_base(void)" (__imp_??0_String_base@std@@QAE@XZ)
LNK2001	unresolved external symbol "__declspec(dllimport) public: __thiscall std::_String_base::_String_base(void)" (__imp_??0_String_base@std@@QAE@XZ)
LNK2001	unresolved external symbol "__declspec(dllimport) public: __thiscall std::_String_base::_String_base(void)" (__imp_??0_String_base@std@@QAE@XZ)
LNK2019	unresolved external symbol "__declspec(dllimport) public: __thiscall std::_Container_base::~_Container_base(void)" (__imp_??1_Container_base@std@@QAE@XZ) referenced in function "public: __thiscall std::_Vector_val<class XCLTlvData *,class std::allocator<class XCLTlvData *> >::~_Vector_val<class XCLTlvData *,class std::allocator<class XCLTlvData *> >(void)" (??1?$_Vector_val@PAVXCLTlvData@@V?$allocator@PAVXCLTlvData@@@std@@@std@@QAE@XZ)
LNK2001	unresolved external symbol "__declspec(dllimport) public: __thiscall std::_Container_base::~_Container_base(void)" (__imp_??1_Container_base@std@@QAE@XZ)
LNK2019	unresolved external symbol "__declspec(dllimport) public: __thiscall std::_Container_base::_Container_base(void)" (__imp_??0_Container_base@std@@QAE@XZ) referenced in function "protected: __thiscall std::_Vector_val<class XCLTlvData *,class std::allocator<class XCLTlvData *> >::_Vector_val<class XCLTlvData *,class std::allocator<class XCLTlvData *> >(class std::allocator<class XCLTlvData *>)" (??0?$_Vector_val@PAVXCLTlvData@@V?$allocator@PAVXCLTlvData@@@std@@@std@@IAE@V?$allocator@PAVXCLTlvData@@@1@@Z)
LNK2001	unresolved external symbol "__declspec(dllimport) public: __thiscall std::_Container_base::_Container_base(void)" (__imp_??0_Container_base@std@@QAE@XZ)
LNK2019	unresolved external symbol "__declspec(dllimport) public: __thiscall std::exception::exception(void)" (__imp_??0exception@std@@QAE@XZ) referenced in function "public: __thiscall std::logic_error::logic_error(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0logic_error@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z)
LNK2001	unresolved external symbol "__declspec(dllimport) public: __thiscall std::exception::exception(void)" (__imp_??0exception@std@@QAE@XZ)
LNK2001	unresolved external symbol "__declspec(dllimport) public: __thiscall std::exception::exception(char const * const &)" (__imp_??0exception@std@@QAE@ABQBD@Z)
LNK2001	unresolved external symbol "__declspec(dllimport) public: __thiscall std::exception::exception(char const * const &)" (__imp_??0exception@std@@QAE@ABQBD@Z)
LNK2001	unresolved external symbol "__declspec(dllimport) public: __thiscall std::exception::exception(char const * const &)" (__imp_??0exception@std@@QAE@ABQBD@Z)
LNK2001	unresolved external symbol "__declspec(dllimport) public: __thiscall std::exception::exception(char const * const &)" (__imp_??0exception@std@@QAE@ABQBD@Z)
LNK2001	unresolved external symbol "__declspec(dllimport) public: __thiscall std::exception::exception(char const * const &)" (__imp_??0exception@std@@QAE@ABQBD@Z)
LNK2001	unresolved external symbol "__declspec(dllimport) public: __thiscall std::exception::exception(char const * const &)" (__imp_??0exception@std@@QAE@ABQBD@Z)
LNK2001	unresolved external symbol "__declspec(dllimport) public: __thiscall std::exception::exception(char const * const &)" (__imp_??0exception@std@@QAE@ABQBD@Z)
LNK2019	unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >(struct std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >::_Has_debug_it)" (__imp_??0?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@U_Has_debug_it@01@@Z) referenced in function "class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > __cdecl XCL::parseSemiOctetRepresentation(class std::basic_string<unsigned char,struct std::char_traits<unsigned char>,class std::allocator<unsigned char> > const &)" (?parseSemiOctetRepresentation@XCL@@YA?AV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@ABV?$basic_string@EU?$char_traits@E@std@@V?$allocator@E@2@@3@@Z)
LNK2019	unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(struct std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Has_debug_it)" (__imp_??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@U_Has_debug_it@01@@Z) referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl XCL::encodeAsString<long>(long,enum XCL::ENUM_ENCODE_MODE,long)" (??$encodeAsString@J@XCL@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@JW4ENUM_ENCODE_MODE@0@J@Z)
LNK2001	unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(struct std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::_Has_debug_it)" (__imp_??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@U_Has_debug_it@01@@Z)


VS2005: CVT1100: duplicate resource. type:ICON, name:1, language:0x0000

$
0
0
Hello,

I have got two resource files in a project.
The first resource file has dialogs, menus, strings, icons and a toolbar.
The second resource file has only string resources.
I added a new icon to my second resource file and compiled and all was fine. But after I set the language of the icon to type neutral I get the following fatal error with Visual Studio 2005:

1>CVTRES : fatal error CVT1100: duplicate resource. type:ICON, name:1, language:0x0000
1>LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt

The icon name is IDI_ICON1 and the number of the icon in the resource header file is 2209 an no other icon has the same number in the whole project.

I also changed the /TLBID:id to 2, 4711, 65535 but this has no effect.

Can somebody help me,

Thanks,

Andreas.

How to get the names of users accessing the shared file?

$
0
0

Hi There,

We have a windows desktop application, using which user can access files stored, either in a shared folder like \\RemoteComputer\Folder OR a folder on local system.

In case, if there is an update on a file, stored in shared folder, and if that is already open by some other user(s), then we need to display a pop up, showing the username(s) who have opened that shared file?

Is it possible to have such list of user names? If yes, then which API, I can use for that?

Thanks.

Track click event in dialog

$
0
0

Hi,

In my MDI application I have a button in a MFC Dialog. When clicking the button I am displaying a popup modeless dialog . When clicking outside of the newly created popup dialog I am destroying that dialog.

In the newly created dialog, I overrode the OnActivate() and when getting  nstate as WA_INACTIVE, I am destroying the dialog.

Now My requirement is 

1. When I click the button second time if the popup dialog is destroyed by clicking outside of the dialog other than this button, I have to display the popup dialog again.

2.When I click the button second time if the popup dialog is destroyed by clicking on this button , I should not display the dialog.

OnActivate event of the new popup dialog is getting called before the OnButtonClick of the parent dialog. Whenever I go to OnButtonClick the new popup dialog is in destroyed state only.

In onActivate the pWndOther is always giving cmainframe window when nstate is WA_INACTIVE.

How to get whether user clicked on the button or any other control or dialog or mainframe or view?


Help me MFC CBitmap CreateCompatibleBitmap assertion

$
0
0
 Dear ladies and gentlemen

My program is throwing a debug assertion error.

afxcmn.inl line 419

what is this line 419 in afxcmn.inl? Explanation please?

I am using MFC CBitmap CreateCompatibleBitmap.


Thanks in advance!


How to set event from service and wait in a thread in dll?

$
0
0
I need to create and set event from a windows service  and I need to wait for that in a dll in a thread. How can i do it? when I am creating and setting the event  from a console application it works fine but when I am doing same from service the event doesn't reach to the thread or dll.

Writing and reading from/to a pipe from multiple threads

$
0
0

I am trying to create a named pipe(server) from one thread then I wait for the client to connect in separate thread and in client I call CreateFile() and later write to the pipe using that handle, and in the server itself I create another thread to write to the same pipe using same handle I got from CreateNamedPipe(). Whatever the client write I am getting that in the server but whatever I write from the thread in server I am not getting it in the read thread even though the WriteFile() is successful. What is the issue?

Server code:

#include "windows.h"
#include <stdio.h>
#include <string.h>
#include <thread>

//Name given to the pipe
#define g_szPipeName L"\\\\.\\Pipe\\MyNamedPipe1"
//Pipe name format - \\.\pipe\pipename

HANDLE hPipe;
DWORD cbBytes;
#define BUFFER_SIZE 1024 //1k
char szBuffer[BUFFER_SIZE];
#define ACK_MESG_RECV "Message received successfully"
extern "C"
void WriteToPipe(PHANDLE hPipe)
{
	//gets_s(szBuffer);
	//Reply to client
	static int i = 100;
	BOOL bResult = false;
	while (1)
	{
		//Send the message to server
		bResult = WriteFile(
			*hPipe,                // handle to pipe &i,
			sizeof(i),   // number of bytes to write, include the NULL&cbBytes,             // number of bytes written 
			NULL);                // not overlapped I/O 
		Sleep(3000);
		if ((!bResult) || (sizeof(i) != cbBytes))
		{
			printf("\nError occurred while writing  to the server: %d\n", GetLastError());
			//CloseHandle(hPipe);
			continue;
		}
		else
		{
			printf("\nWriteFile() was successful.\n");
		}
		i++;
	}
	CloseHandle(*hPipe);
}

void ReadFromPipe( PHANDLE hPipe)
{
	//gets_s(szBuffer);
	//Reply to client
	int i;
	OVERLAPPED					olStruct;
	ZeroMemory(&olStruct, sizeof(olStruct));

	BOOL bSuccess = false;
	if(!(olStruct.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL)))
	{
		printf("\nCreate event failed with error:%d", GetLastError());
	}
	while (1)
	{
		BOOL bResult = ReadFile(
		*hPipe,                // handle to pipe &i,             // buffer to receive data 
		sizeof(i),     // size of buffer &cbBytes,             // number of bytes read &olStruct);                // not overlapped I/O 

		if (!bResult)
		{
			DWORD dwLastError = GetLastError();
			if (dwLastError != ERROR_IO_PENDING)//shouldn't be successfull, should be ERROR_IO_PENDING
			{
				printf("ReadFile Success with error %u\n", dwLastError);
			}
			else
				printf("ReadFile %u\n", dwLastError);
		}
		else
			printf("ReadFile succeeded\n");

		DWORD dwRet = WaitForSingleObject(olStruct.hEvent, 3000);
		DWORD index;
		printf("Wait result = 0x%x\n", dwRet);
		if (dwRet == 0)
		{
			{
				// This blocks until we receive a value from the interrupt handler.
				bSuccess = GetOverlappedResult(
					*hPipe,&olStruct,&index,
					FALSE);

				if (bSuccess)
				{
					printf("ReadFile() was successful.\n");
					if (i)
						printf("Client sent the following message: %d\n", i);
					i = 0;
				}
				else
				{
					printf("\nError occurred while reading ""from the client: %d\n", GetLastError());
					continue;
				}
			}
		}
	//if ((!bResult) || (0 == cbBytes))
	//{
	//	printf("\nError occurred while reading "
	//		"from the client: %d", GetLastError());
	//	//CloseHandle(*hPipe);
	//}
	//else
	//{
	//	printf("\nReadFile() was successful.");
	//}

		//i++;
	//i = 0;
		Sleep(3000);
	}
	ResetEvent(olStruct.hEvent);
	CloseHandle(olStruct.hEvent);
	CloseHandle(*hPipe);
}
int main(int argc, char* argv[])
{

	hPipe = CreateNamedPipe(
		g_szPipeName,             // pipe name 
		PIPE_ACCESS_DUPLEX,       // read/write access 
		PIPE_TYPE_MESSAGE |       // message type pipe 
		PIPE_READMODE_MESSAGE |   // message-read mode 
		PIPE_WAIT,                // blocking mode 
		PIPE_UNLIMITED_INSTANCES, // max. instances  
		BUFFER_SIZE,              // output buffer size 
		BUFFER_SIZE, 
		NMPWAIT_USE_DEFAULT_WAIT, // client time-out 
		NULL);                    // default security attribute 

	if (INVALID_HANDLE_VALUE == hPipe)
	{
		printf("\nError occurred while creating the pipe: %d\n", GetLastError());
		return 1;  //Error
	}
	else
	{
		printf("\nCreateNamedPipe() was successful.\n");
	}

	printf("\nWaiting for client connection...\n");


	//Wait for the client to connect
	BOOL bClientConnected = ConnectNamedPipe(hPipe, NULL);

	
	std::thread second(ReadFromPipe, &hPipe);
	std::thread first(WriteToPipe, &hPipe);


	//if (FALSE == bClientConnected)
	//{
	//	printf("\nError occurred while connecting"
	//		" to the client: %d", GetLastError());
	//	CloseHandle(hPipe);
	//	return 1;  //Error
	//}
	//else
	//{
	//	printf("\nConnectNamedPipe() was successful.");
	//}

	
	

	//We are connected to the client.
	//To communicate with the client 
	//we will use ReadFile()/WriteFile() 
	//on the pipe handle - hPipe

	////Read client message
	//BOOL bResult = ReadFile(
	//	hPipe,                // handle to pipe 
	//	szBuffer,             // buffer to receive data 
	//	sizeof(szBuffer),     // size of buffer 
	//	&cbBytes,             // number of bytes read 
	//	NULL);                // not overlapped I/O 

	//if ((!bResult) || (0 == cbBytes))
	//{
	//	printf("\nError occurred while reading "
	//		"from the client: %d", GetLastError());
	//	CloseHandle(hPipe);
	//	return 1;  //Error
	//}
	//else
	//{
	//	printf("\nReadFile() was successful.");
	//}

	//printf("\nClient sent the following message: %s", szBuffer);

	//strcpy_s(szBuffer, ACK_MESG_RECV);

	
	//while (true)
	//{
	//	printf("Enter string:");
	//	gets_s(szBuffer);
	//	//Reply to client
	//	BOOL bResult = WriteFile(
	//		hPipe,                // handle to pipe 
	//		szBuffer,             // buffer to write from 
	//		strlen(szBuffer) + 1,   // number of bytes to write, include the NULL 
	//		&cbBytes,             // number of bytes written 
	//		NULL);                // not overlapped I/O 

	//	if ((!bResult) || (strlen(szBuffer) + 1 != cbBytes))
	//	{
	//		printf("\nError occurred while writing to the client: %d\n", GetLastError());
	//		CloseHandle(hPipe);
	//		return 1;  //Error
	//	}
	//	else
	//	{
	//		printf("\nWriteFile() was successful.\n");
	//	}
	//}
	//CloseHandle(hPipe);
	return 0; //Success
}

Client code:

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


//Name given to the pipe
#define g_szPipeName L"\\\\.\\Pipe\\MyNamedPipe1"
//Pipe name format - \\servername\pipe\pipename
//This pipe is for server on the same computer, 
//however, pipes can be used to
//connect to a remote server

#define BUFFER_SIZE 1024 //1k
#define ACK_MESG_RECV "Message received successfully"

int main(int argc, char* argv[])
{
	HANDLE hPipe;
		DWORD cbBytes;
	BOOL bResult;
	static int i = 10;

	//Connect to the server pipe using CreateFile()
	hPipe = CreateFile(
		g_szPipeName,   // pipe name 
		GENERIC_READ |  // read and write access 
		GENERIC_WRITE,
		FILE_SHARE_WRITE | FILE_SHARE_READ,              // no sharing 
		NULL,           // default security attributes
		OPEN_EXISTING,  // opens existing pipe 
		0,              // default attributes 
		NULL);          // no template file 

	if (INVALID_HANDLE_VALUE == hPipe)
	{
		printf("\nError occurred while connecting"" to the server: %d\n", GetLastError());
		//One might want to check whether the server pipe is busy
		//This sample will error out if the server pipe is busy
		//Read on ERROR_PIPE_BUSY and WaitNamedPipe() for that
		return 1;  //Error
	}
	else
	{
		printf("\nCreateFile() was successful.\n");
	}

	//We are done connecting to the server pipe, 
	//we can start communicating with 
	//the server using ReadFile()/WriteFile() 
	//on handle - hPipe

	//char szBuffer[BUFFER_SIZE];

	//printf("\nEnter a message to be sent to the server: ");
	//scanf_s("%s", szBuffer, BUFFER_SIZE-1);


	while (1)
	{
		//Send the message to server
		bResult = WriteFile(
			hPipe,                // handle to pipe 
			&i,
			sizeof(i),   // number of bytes to write, include the NULL&cbBytes,             // number of bytes written 
			NULL);                // not overlapped I/O 
		Sleep(3000);
		if ((!bResult) || (sizeof(i) != cbBytes))
		{
			printf("\nError occurred while writing"" to the server: %d\n", GetLastError());
			CloseHandle(hPipe);
			return 1;  //Error
		}
		else
		{
			printf("\nWriteFile() was successful.\n");
		}
		i++;
		Sleep(3000);
	}
	//while (true)
	//{
	//	printf("Ïn while waiting for read\n");
	//	//Read server response
	//	BOOL bResult = ReadFile(
	//		hPipe,                // handle to pipe 
	//		szBuffer,             // buffer to receive data 
	//		sizeof(szBuffer),     // size of buffer 
	//		&cbBytes,
	//		NULL);

	//	if ((!bResult) || (0 == cbBytes))
	//	{
	//		printf("\nError occurred while reading from the server: %d\n", GetLastError());
	//		CloseHandle(hPipe);
	//		return 1;  //Error
	//	}
	//	else
	//	{
	//		printf("\nReadFile() was successful.\n");
	//	}

	//	printf("\nServer sent the following message: %s\n", szBuffer);
	//}

	CloseHandle(hPipe);
	return 0; //Success
}

Please help.

Not compiling without extern

$
0
0

I have this piece of code:

ConsoleApplication.cpp

#include <iostream>

extern int* const * const def[];

int main()
{
    printf("%p\n", def[0][0]);
}

test.cpp

int test;

int* const abc[] =
{
    &test
};

extern int* const * const def[] = 
{
    abc
};

And I don't think the extern is needed for the definition. GCC is actually giving me a warning that an extern is not allowed to be initialized. But when I try to compile it using VS 2017 (15.9.2) it just won't compile. Am I doing something strange here or is this a compiler fault?

It is actually some code that is generated by IsoAgLib (http://www.isoaglib.com), slimmed down as small as I could think of, where I am trying to fix the warnings.

Event Log Monitoring via WMI or the Event Log API - like EvtSubscribe?

$
0
0
When monitoring the event log for certain event IDs, are there advantages/disadvantages to using EvtSubscribe and the related "Windows Event Log" functions over using WMI and querying Win32_NTLogEvent? I've used WMI in the past and, while complicated to setup and use, has functioned quite nicely. I've recently become aware of the "Windows Event Log" API (https://docs.microsoft.com/en-us/windows/desktop/wes/windows-event-log) , and was wondering if it might provide the same information, or if there are any limitations relative to WMI.

Forms in C++ like in VB

$
0
0
I've been using VB6 for many years and I thought I'd try the new VS-2017 with VB.net.  It's tough going but I'm kinda getting the hang of it, I guess.  C++ seem to be very popular and I thought I'd check it out.  But unlike VB, where a Form appears when you start it (under Windows Forms App option), in C++ there's nothing... no Form, and I see no way to add one. Am I missing something here?

BiggyD

Viewing all 15302 articles
Browse latest View live


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