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

How to scroll main window content?

$
0
0

I have the main window that has lots of buttons, images text areas etc. inside.

How do I add vertical scrolling to the window?

I added WS_VSCROLL to CreateWindow, so now I have the scrollbar that does nothing.

Do I need to manually decide and describe how to redraw all different elements inside the main window or is there some  generic code /  function that will do it for any kind of content that I could use?

Thank you


What does uint32_t mean ?

$
0
0

I find in code the following instructions. What do they mean ? 

uint32_t
uint64_t
uint8_t

Kind Regards, 

Th0m4$


Embedding web url in window instance

$
0
0
Hi I am trying to embed and open a web url in a window instance, would anyone have any pointers on how to go about this?

Scott Mandrell

REST? how can this work?

$
0
0

I've some problems understanding the idea behind REST. Can someone explain me how this can ever work? ... whitout session on the server it's already pretty difficult to do a login. ... well, no, that's not the correct word. Not difficult, but pretty inefficient. I would have to send the session always within my request. And... how would you do a Diffie-Hellman in a REST environment? ... to be honest. To me it seems to be an idea like communism. Totally overshot the target. ... as far as I understood this, it's comming from people having problems with things like rpc (those crap implementation we had) ... but, in the end... is not everything "rpc" ... a "remote procedure call" ? ... what happens if you send a "GET" command in http to the server? It unpacks it and calls a function internally... so, isn't this rpc then?? (ok, that's a second question... but, that's why I marked it as "discussion").

... ok, could have asked this in an other forum. But I cannot move it ...



How do I start the Visual Studio IDE ?

$
0
0

How do I start the Visual Studio IDE so that I can start coding a C++ program?

How do I edit that code once I have entered it ?

LNK2019 - VS13 - C++ - Lumberyard - CryEngine

$
0
0

hello,

first of all : All of my declared functions (in the headers) are also defined (in the cpp files) . my templates are all defined in the headers.

I assume that the linker doesnt find the files even though the auto completion does.

to the problem:

i get a LNK2019 error by calling the constructor of the "UiTransform2dComponent" class, but the constructor is defined in the cpp file. if i remove the line

CreateComponentNew<UiTransform2dComponent>(buttonElem);

it will compile fine.

AZ::Entity* CreateUIElements::CreateButtonNew(const char* name, bool atRoot, AZ::EntityId parent, UiTransform2dInterface::Anchors anchors, UiTransform2dInterface::Offsets offsets, const char* text, ColorF baseColor, ColorF selectedColor, ColorF pressedColor, ColorF textColor)
	{
		AZ::Entity* buttonElem = nullptr;
		if (atRoot)
		{
			EBUS_EVENT_ID_RESULT(buttonElem, parent, UiCanvasBus, CreateChildElement, name);
		}
		else
		{
			EBUS_EVENT_ID_RESULT(buttonElem, parent, UiElementBus, CreateChildElement, name);
		}

	{
		AZ::EntityId buttonId = buttonElem->GetId();
		// create components for button elem
		//AZ::Component* component = buttonElem->CreateComponent<UiTransform2dComponent>();
		//buttonElem->CreateComponent<UiTransform2dComponent>();
		CreateComponentNew<UiTransform2dComponent>(buttonElem);
		//UiTransform2dComponent* t = new UiTransform2dComponent();
		//CreateComponentNew<UiImageComponent>(buttonElem);
		//CreateComponent<UiButtonComponent>(buttonElem);

		buttonElem->Init();
		buttonElem->Activate();

		CRY_ASSERT_MESSAGE(UiTransform2dBus::FindFirstHandler(buttonId), "Transform2d component missing");

		EBUS_EVENT_ID(buttonId, UiTransform2dBus, SetAnchors, anchors, false, false);
		EBUS_EVENT_ID(buttonId, UiTransform2dBus, SetOffsets, offsets);
		EBUS_EVENT_ID(buttonId, UiImageBus, SetColor, baseColor);

		EBUS_EVENT_ID(buttonId, UiButtonBus, SetSelectedColor, selectedColor);
		EBUS_EVENT_ID(buttonId, UiButtonBus, SetPressedColor, pressedColor);

		string pathname = "Textures/Basic/Button_Sliced_Normal.sprite";
		ISprite* sprite = gEnv->pLyShine->LoadSprite(pathname);

		EBUS_EVENT_ID(buttonId, UiImageBus, SetSprite, sprite);
		EBUS_EVENT_ID(buttonId, UiImageBus, SetImageType, UiImageInterface::ImageType::Sliced);
	}

	{
		// create child text element for the button
		AZ::Entity* textElem = nullptr;
		EBUS_EVENT_ID_RESULT(textElem, buttonElem->GetId(), UiElementBus, CreateChildElement, "ButtonText");
		AZ::EntityId textId = textElem->GetId();

		//CreateComponent<UiTransform2dComponent>(textElem);
		//CreateComponent<UiTextComponent>(textElem);
		textElem->Init();
		textElem->Activate();

		CRY_ASSERT_MESSAGE(UiTransform2dBus::FindFirstHandler(textId), "Transform component missing");

		EBUS_EVENT_ID(textId, UiTransform2dBus, SetAnchors, UiTransform2dInterface::Anchors(0.5, 0.5, 0.5, 0.5), false, false);
		EBUS_EVENT_ID(textId, UiTransform2dBus, SetOffsets, UiTransform2dInterface::Offsets(0, 0, 0, 0));

		EBUS_EVENT_ID(textId, UiTextBus, SetText, text);
		EBUS_EVENT_ID(textId, UiTextBus, SetTextAlignment, IDraw2d::HAlign::Center, IDraw2d::VAlign::Center);
		EBUS_EVENT_ID(textId, UiTextBus, SetColor, textColor);
		EBUS_EVENT_ID(textId, UiTextBus, SetFontSize, 24.0f);
	}

	return buttonElem;

my header file:

#include <LyShine/Bus/UiButtonBus.h>
#include <LyShine/Bus/UiTextInputBus.h>

#include "../LyShine/UiTransform2dComponent.h"
#include "../LyShine/UiImageComponent.h"
#include "../LyShine/UiButtonComponent.h"
#include "../LyShine/UiTextComponent.h"
#include "../LyShine/UiTextInputComponent.h"

#ifndef CreateUIElements_H
#define CreateUIElements_H

class CreateUIElements {
public :
	template <typename T>
	void CreateComponentNew(AZ::Entity* entity) {
		//T* component = entity->CreateComponentNew<T>();
		AZ::Component* component = entity->CreateComponent<T>();
		//AZ::Component* component = entity->CreateComponent<T>();
		//CRY_ASSERT_MESSAGE(component, "Failed to create component");
	};

	AZ::Entity* CreateButtonNew(const char* name, bool atRoot, AZ::EntityId parent, UiTransform2dInterface::Anchors anchors, UiTransform2dInterface::Offsets offsets,const char* text, ColorF baseColor, ColorF selectedColor, ColorF pressedColor, ColorF textColor);
	// AZ::Entity* CreateText(const char* name, bool atRoot, AZ::EntityId parent, UiTransform2dInterface::Anchors anchors, UiTransform2dInterface::Offsets offsets, const char* text, ColorF textColor, IDraw2d::HAlign hAlign, IDraw2d::VAlign vAlign);
	// AZ::Entity* CreateTextInput(const char* name, bool atRoot, AZ::EntityId parent, UiTransform2dInterface::Anchors anchors, UiTransform2dInterface::Offsets offsets, const char* text, const char* placeHolderText, ColorF baseColor, ColorF selectedColor, ColorF pressedColor, ColorF textColor, ColorF placeHolderColor);

};
#endif 


part of the entity header. creating the new component causes the LNK error.

        template<class ComponentType>
        ComponentType* CreateComponent()
        {
			ComponentType* component = new ComponentType();
            if (component)
            {
                AddComponent(component);
            }
            return component;
        }

and here is definition of the constructor for the  UiTransform2dComponent

UiTransform2dComponent::UiTransform2dComponent()
{
	m_pivot = (Vec2(0.5f, 0.5f));
	m_rotation = (0.0f);
	m_scale = (Vec2 (1.0f, 1.0f));
	m_scaleToDevice = (false);
}
    

doing this will throw an LNK error too:

UiTransform2dComponent* t = new UiTransform2dComponent()

the error message:

Error	560	error LNK2019: unresolved external symbol "public: __cdecl UiTransform2dComponent::UiTransform2dComponent(void)" (??0UiTransform2dComponent@@QEAA@XZ) referenced in function "public: class UiTransform2dComponent * __cdecl AZ::Entity::CreateComponent<class UiTransform2dComponent>(void)" (??$CreateComponent@VUiTransform2dComponent@@@Entity@AZ@@QEAAPEAVUiTransform2dComponent@@XZ)	c:\Amazon\Lumberyard\1.1.0.0\dev\Solutions\LumberyardSDK.depproj\CreateUIElements.cpp.104.obj	_WAF_




x64 asm

$
0
0

Good day. Where I can find full documentation for x64 asm (MASM)?

Some operators or directives not work in x64 (but work in x86_32)

Example:

SomeStruct STRUCT
    var1 DWORD ?
SomeStruct ENDS

......

movzx eax, (SomeStruct PTR [rsi]).var1

or

s SomeStruct <>

......

push OFFSET s

LNK error 2019 with crthandlerssettler

$
0
0

Hi,

Can anyone please help me in resolving this linked errors.

error LNK2019: unresolved external symbol "extern "C" int __cdecl _CrtSetReportMode(int,int)" (?_CrtSetReportMode@@$$J0YAHHH@Z) referenced in function "public: __thiscall Microsoft::VisualStudio::CppUnitTestFramework::TestClassImpl::CrtHandlersSetter::CrtHandlersSetter(void)" (??0CrtHandlersSetter@TestClassImpl@CppUnitTestFramework@VisualStudio@Microsoft@@$$FQAE@XZ)

error LNK2019: unresolved external symbol "extern "C" void * __cdecl _CrtSetReportFile(int,void *)" (?_CrtSetReportFile@@$$J0YAPAXHPAX@Z) referenced in function "public: __thiscall Microsoft::VisualStudio::CppUnitTestFramework::TestClassImpl::CrtHandlersSetter::CrtHandlersSetter(void)" (??0CrtHandlersSetter@TestClassImpl@CppUnitTestFramework@VisualStudio@Microsoft@@$$FQAE@XZ)

Thanks for the help...

Regards,

Ravi Raj Nukala


Cheers, Ravi.N.Raj


Catastrophic failures in ClassWizard VS2015, Update 2

$
0
0

Using class wizard this morning I'm starting to get catastrophic failures after adding a number of functions to a class.  It seems to happen after using the add event option in the ribbon editor, which is painfully slow particularly adding a number of member functions for a number of buttons.  Class wizard is also slow (~20 seconds to add a member function) but better at adding more than one member at a time.

Is there any way of cleaning up the class wizard files to speed things up and makes them more reliable?  The .sdf file associated with my project is 246mb and I also see a .VC.DB file of 172mb.  Back in the early days of Visual C++ class wizard data was held in a .CLW text file which could be edited easily enough.  VS version details and crash screen below.

Microsoft Visual Studio Professional 2015
Version 14.0.25123.00 Update 2
Microsoft .NET Framework
Version 4.6.01055

Installed Version: Professional

Visual Basic 2015   00325-60000-80195-AA437
Microsoft Visual Basic 2015

Visual C# 2015   00325-60000-80195-AA437
Microsoft Visual C# 2015

Visual C++ 2015   00325-60000-80195-AA437
Microsoft Visual C++ 2015

Application Insights Tools for Visual Studio Package   5.2.60328.3
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2015.1 (Beta8)   14.1.11106.0
ASP.NET and Web Tools 2015.1 (Beta8)

ASP.NET Web Frameworks and Tools 2012.2   4.1.41102.0
For additional information, visit http://go.microsoft.com/fwlink/?LinkID=309563

ASP.NET Web Frameworks and Tools 2013   5.2.40314.0
For additional information, visit http://www.asp.net/

Common Azure Tools   1.7
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

InstallShield Limited Edition   
InstallShield. For more information visit the Flexera Software website at <http://www.FlexeraSoftware.com>. Copyright © 2015 Flexera Software LLC. All Rights Reserved.

JavaScript Language Service   2.0
JavaScript Language Service

JavaScript Project System   2.0
JavaScript Project System

Microsoft Azure Mobile Services Tools   1.4
Microsoft Azure Mobile Services Tools

NuGet Package Manager   3.4.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

SQL Server Data Tools   14.0.60311.1
Microsoft SQL Server Data Tools

TypeScript   1.8.30.0
TypeScript tools for Visual Studio

Visual Assist   
For more information about Visual Assist, see the Whole Tomato Software website at http://www.WholeTomato.com. Copyright (c) 1997-2016 Whole Tomato Software, Inc.

Visual Commander   2.3
For more information about Visual Commander, see the website at https://vlasovstudio.com/visual-commander/.
Copyright (c) 2013-2015 Vlasov Studio.

Visual Studio Tools for Universal Windows Apps   14.0.24720.00
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.

Catastrophic failure

cmfctoolbar and user bitmap

$
0
0

Hi,

I would like to use an image collection, and button and only this in my toolbar.

I'm trying to use SetUserImages and InsertButton from my CMFCToolBar, but ... nothing is displayed

I'm thinking I've made something wrong, no call to loadbitmap nor loadtoolbar, but OnPaint test pImage validity which is avery times wrong.

could anyone help me please ?

Thanks

Yan

GattDeviceService::FromIdAsync won't create the service

$
0
0

I'm working from the Heart Rate Monitor example presented in

https://code.msdn.microsoft.com/windowsapps/Bluetooth-Generic-5a99ef95#content I only have changed the UUID so it connects to the generic access (0x1800) service on my own BLE device. The device does appear but when I click on it, the service is not created. As far as I understand, the operation

return create_task(GattDeviceService::FromIdAsync(device->Id))
            .then([this, device] (GattDeviceService^ service)

doesn't work or at least the access is not granted, so the verification

if (service != nullptr)
            {
                this->service = service;
                IsServiceInitialized = true;
                return ConfigureServiceForNotificationsAsync();
            }
            else
            {
				MainPage::Current->NotifyUser(device->Id, NotifyType::StatusMessage);
            }

is false and the program stops.

The device is well paired, otherwise it would be found by the code.

I managed to get the Device ID  returned by windows, which is this:
\\?\BTHLEDevice#{00001800-0000-1000-8000-00805f9b34fb}_d2f28afd324a#&&1a50d254&9&001#{6e3bbb679-4372-40c8-9eaa-4509df2-60cd8}

What am I doing wrong?


Linker Error in VS2015

$
0
0

Recently migrated all VC++ projects from VS2012 to VS2015, all the other projects compiled fine. There is one project that is giving a linker error in VS2015. It worked fine in VS2012.

That project has references to 2 libs, rpcns4.lib and rpcrt4.lib in its project settings.

The linker error is...

error LNK2019: unresolved external symbol _memcmp referenced in function _DllCanUnloadNow@0

Any help is resolving this error will be great.

Programatically change the default playback device in windows system?

$
0
0
Under windows 7 or 8 is  there  any way to change window system audio playback device (i.e HDMI to Headphones).

Change in generated binary code on different machines using same Visual studio.

$
0
0

Hello all,

I & my friend use Visual studio 2008 Professional Edition Version 9.0.21022.8 RTM
Microsoft .NET Framework Version 3.5 SP1.

I have written following code in a function for declaring an array of characters:

char szTemp[1024] = {'\0'};

I compile this function using following options

>cl /GS- /D /Oi- /LD /W3

and link using following options:

>link  /NODEFAULTLIB

machine code generated at my computer for above line is simply 

rep stosd

stosw

stosb

instructions.

But when I compile same function on my Friends computer I get machine code calling to memset() function as folowos

push 3ff

push 0

push eax ; eax contains address of stack i.e buffer

call 401c80 ;this is memset function.

We both use windows 7 Professional SP1 on x64 based machine.

Can anyone tell me why this difference is observed?

Also is there any way to generate same code on both the machines?

Also let me know if I need to provide any additional information.

Thanks in advance,

sb.Ajay


Main title bar text not visible when window maximized on Windows 10

$
0
0

When MFC-based application has the main window maximized on Windows 10, the title of the window/application disappears (it's white text on white background). This happens when 'Application look' is set to anything else than 'Windows XP'.

If user sets 'Settings'-'Personalization'-'Colors'-'Show color on Start, taskbar, action center and title bar' to ON, then the main window title appears again.

This happens on MFC-based SDI-type applications with ribbon, please see screenshots below. Have verified on application compiled with VS2012 and VS2015.

When dialog is maximized:

When dialog as a regular window:


CEdit PosFromChar() broken?

$
0
0

Same as https://social.msdn.microsoft.com/Forums/vstudio/en-US/5740af95-ec61-4f6a-b46b-ad22521e4609/cedit-posfromchar-broken

but nothing has changed since 2011. The documentation is still wrong and / or the function is not doing what the documentation says. 

If the documentation is wrong how do I get the point behind the last character, I want to call SetCaretPos(point) to move the caret.

Thanks for the help,


Andreas

CMFCMaskedEdit OnPaste problem when no mask is enabled and text is selected (Visual Studio 2015 Prof. Update 2)

$
0
0

Nearly the same as in https://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/792e8c94-2d9b-4e8c-b597-7ac39764f564/#2b256084-e023-482f-b089-1498049f63fd. If text is selected the text is not replaced instead the pasted text is inserted in front of the selection.

Workaround:

      const int nSelected = nEndOld - nBeginOld;

 __super::OnPaste();

      // Hack Begin: CMFCMaskedEdit __super::OnPaste() inserts the string instead of replacing it, so we must remove the previously selected portion ourself
      CString str;
      GetWindowText(str);

      const int nInserted = str.GetLength() - strOld.GetLength();
      const int nLeft = nBeginOld + nInserted;
      CString strNew(str);
      strNew = strNew.Left(nLeft);
      strNew += str.Right(strOld.GetLength() - nEndOld);
      SetWindowText(strNew);
      SetSelEx(nLeft, nLeft);
      // Hack End



Andreas

Windows 10 and Registry Key

$
0
0

Hi Folks

I have been adding a registry key in HKLM\Microsoft\Windows\CurrentVersion\Run with my installer. This works fine for Windows 7, but the registry entry doesn't get created for Windows 10.

Any help is appreciated

Thanks

Anu 


Anu Viswan : www.AnuViswan.blogspot.com

"filename".exe is stopped working

$
0
0

Hi,

My name is Ravi Shankar,

I am copying Draft_model(application file generated after build) to different folders and trying to run for parallel execution of the code for different inputs. When I try to do that, message "draft_model.exe is stopped working" is popping up.

Please help me with this.

Unresolved allocations in VS2015 memory profiling

$
0
0

Hello!

I am having problems with fully utilizing memory profiling capabilities of Visual Studio 2015 in my C++ application (I am building the application with VS2015 (v140) platform toolset)

The memory profiling tool seems to have no problems with assigning types to objects allocated with the 'new' keyword (and with displaying this information in heap snapshots). However a lot of the old code in the application uses '_aligned_malloc' for heap memory allocations and these allocations are categorized as "Unresolved allocations" in heap snapshots.

According to this blog post"allocators in the CRT (new, malloc, …) and Windows SDK have been annotated at the source level so that their allocation data can be captured and mapped to the corresponding symbols", so there is some indication that memory profiler in theory should successfully assign type information to data allocated by '_aligned_malloc'. And indeed, if we look at the declaration of '_aligned_malloc' we will see

_Check_return_ _Ret_maybenull_ _Post_writable_byte_size_(_Size)
_ACRTIMP _CRTALLOCATOR _CRTRESTRICT
void* __cdecl _aligned_malloc(
    _In_ _CRT_GUARDOVERFLOW size_t _Size,
    _In_                    size_t _Alignment
    );

The interesting thing here is '_CRTALLOCATOR' macro, which definition is

#if _MSC_VER >= 1900 && !defined __EDG__ && !defined _CORECRT_BUILD
    #define _CRTALLOCATOR __declspec(allocator)
#else
    #define _CRTALLOCATOR
#endif

So, in the same blog post that I've linked above there is a mention that to allow the memory profiler to gather information from custom allocators one should decorate them with '__declspec(allocator)' which can be seen in the first #if-#endif branch above. But IntelliSense shows that the second #if-#endif branch is actually used and the macro is defined as empty (which essentially means that there is no '__declspec(allocator)' decorating '_aligned_malloc'). One would think that this is why allocations end up in "Unresolved allocations" category. According to IntelliSense '_MSC_VER' == 1900, '_CORECRT_BUILD' is undefined but '__EDG__' == 1. (I wasn't able to dig anything useful about the nature of '__EDG__' macro except that it may be related toEdison Design Group, which product is apparently used in some part of IntelliSense).

What confuses me is that allocations done with the regular 'malloc' (which is also annotated by an empty '_CRTALLOCATOR', so no '__declspec(allocator)') are correctly categorized.

The question is - does the memory profiler supports aligned allocations and what should I do to make the '_aligned_malloc' allocations processed correctly if it does?

Viewing all 15302 articles
Browse latest View live