Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Programming and Hacking > Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 17th March 2019, 07:23   #1  |  Link
stax76
Registered User
 
stax76's Avatar
 
Join Date: Jun 2002
Location: On thin ice
Posts: 6,837
problem writing C++ application

It's been 10 I've not used C++ and even then I wasn't very good so please bear with me.

The very first line I wrote already causes an error.

Can anybody tell me what I miss?

Code:
// aviDrawDX.cpp : Defines the entry point for the application.
//

#include "framework.h"
#include "aviDrawDX.h"
#include "aviDrawDX.h"
#include "shellscalingapi.h"
#include "windows.h"
#include <winuser.h>

#define MAX_LOADSTRING 100

// Global Variables:
HINSTANCE hInst;                                // current instance
WCHAR szTitle[MAX_LOADSTRING];                  // The title bar text
WCHAR szWindowClass[MAX_LOADSTRING];            // the main window class name

// Forward declarations of functions included in this code module:
ATOM                MyRegisterClass(HINSTANCE hInstance);
BOOL                InitInstance(HINSTANCE, int);
LRESULT CALLBACK    WndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK    About(HWND, UINT, WPARAM, LPARAM);

int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
                     _In_opt_ HINSTANCE hPrevInstance,
                     _In_ LPWSTR    lpCmdLine,
                     _In_ int       nCmdShow)
{
	SetProcessDpiAwareness(PROCESS_SYSTEM_DPI_AWARE);
Code:
1>aviDrawDX.obj : error LNK2019: unresolved external symbol SetProcessDpiAwareness referenced in function wWinMain
1>C:\Users\frank\Daten\Projekte\CPP\aviDrawDX\x64\Debug\aviDrawDX.exe : fatal error LNK1120: 1 unresolved externals
1>Done building project "aviDrawDX.vcxproj" -- FAILED.
stax76 is offline   Reply With Quote
Old 17th March 2019, 08:08   #2  |  Link
stax76
Registered User
 
stax76's Avatar
 
Join Date: Jun 2002
Location: On thin ice
Posts: 6,837
Maybe I need to link against a lib file but how do I know what is the name of the lib file? It's not documented in the document for SetProcessDpiAwareness.
stax76 is offline   Reply With Quote
Old 17th March 2019, 08:23   #3  |  Link
stax76
Registered User
 
stax76's Avatar
 
Join Date: Jun 2002
Location: On thin ice
Posts: 6,837
Problem solved, I needed to add shcore.lib in the Linker options.
stax76 is offline   Reply With Quote
Old 17th March 2019, 08:28   #4  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
Quote:
It's not documented in the document for SetProcessDpiAwareness.
Looking at https://docs.microsoft.com/en-us/win...ssdpiawareness which indicates taht SetProcessDpiAwareness belongs to Shellscalingapi.h (https://docs.microsoft.com/en-us/win...ellscalingapi/) and at the bottom of the page you see the requirements:
Quote:
Requirements

Minimum supported client Windows 8.1 [desktop apps only]
Minimum supported server Windows Server 2012 R2 [desktop apps only]
Target Platform Windows
Header shellscalingapi.h
Library Shcore.lib
DLL Shcore.dll
-> what documentation are you looking at?

Cu Selur

Ps.: LOL, you already solved it while I was writing up my reply. Note that this is not supported on Windows 7.
__________________
Hybrid here in the forum, homepage

Last edited by Selur; 17th March 2019 at 08:29. Reason: already solved
Selur is offline   Reply With Quote
Old 17th March 2019, 09:52   #5  |  Link
nevcairiel
Registered Developer
 
Join Date: Mar 2010
Location: Hamburg/Germany
Posts: 10,342
Instead of using the SetProcessDpiAwareness call, I would personally recommend setting DPI Awareness in the manifest. That is fully compatible with any OS version.
__________________
LAV Filters - open source ffmpeg based media splitter and decoders
nevcairiel is online now   Reply With Quote
Old 17th March 2019, 09:55   #6  |  Link
stax76
Registered User
 
stax76's Avatar
 
Join Date: Jun 2002
Location: On thin ice
Posts: 6,837
Thanks, I missed it somehow. In the end if I can get it working it's gonna be a dll used in staxrip which sets DPI awareness already in a Win 7 compatible way.
stax76 is offline   Reply With Quote
Old 19th March 2019, 17:18   #7  |  Link
stax76
Registered User
 
stax76's Avatar
 
Join Date: Jun 2002
Location: On thin ice
Posts: 6,837
What I want to achieve is having a faster preview dialog in StaxRip, it uses GDI+/System.Drawing. The plan is to create a C++ DLL that takes a DIB pointer from the avifile API and renders it using DirectX. I want to create a bitmap from the DIB by calling the function GdipCreateBitmapFromGdiDib, I included the header Gdiplusheaders.h and added the Gdiplus.lib file to the linker options. Now there are many errors:

1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\Gdiplusheaders.h(34): error C2504: 'GdiplusBase': base class undefined
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\Gdiplusheaders.h(39): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\Gdiplusheaders.h(39): error C2143: syntax error: missing ',' before '&'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\Gdiplusheaders.h(40): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\Gdiplusheaders.h(40): error C2143: syntax error: missing ',' before '&'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\Gdiplusheaders.h(40): error C2535: 'Region::Region(const int)': member function already defined or declared
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\Gdiplusheaders.h(39): note: see declaration of 'Region::Region'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\Gdiplusheaders.h(41): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\Gdiplusheaders.h(41): error C2143: syntax error: missing ',' before '*'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\Gdiplusheaders.h(41): error C2535: 'Region::Region(const int)': member function already defined or declared
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\Gdiplusheaders.h(39): note: see declaration of 'Region::Region'
1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\Gdiplusheaders.h(49): error C3646: 'MakeInfinite': unknown override specifier

I'm using VS 2019 RC with newest SDK and plattform toolkit, in VS 2017 I can't compile anything C++, I've tried to compile my Open with++ shell extension and nomatter what I've tried it wouldn't compile successfully in VS 2017.

What could be the reason for the errors? Do I have to add a search directory somewhere VS to look for headers? Did I meantion I'm not very good in C++?
stax76 is offline   Reply With Quote
Old 19th March 2019, 17:49   #8  |  Link
lvqcl
Registered User
 
Join Date: Aug 2015
Posts: 293
From MSDN page:
Quote:
Header

Gdiplusheaders.h (include Gdiplus.h)
which means that you need to include Gdiplus.h, and not Gdiplusheaders.h directly.
lvqcl is offline   Reply With Quote
Old 19th March 2019, 18:32   #9  |  Link
stax76
Registered User
 
stax76's Avatar
 
Join Date: Jun 2002
Location: On thin ice
Posts: 6,837
that works nicely, thanks.
stax76 is offline   Reply With Quote
Old 3rd April 2019, 15:19   #10  |  Link
stax76
Registered User
 
stax76's Avatar
 
Join Date: Jun 2002
Location: On thin ice
Posts: 6,837
Maybe someone can give me a hint which APIs or source codes I can use to draw a RGB 24 DIB returned by the avifile API. I want to draw to a win32 window handle and it has to be fast so no GDI+. I'm much of a C++ beginner but won't give up on this until I get something done that works.
stax76 is offline   Reply With Quote
Old 3rd April 2019, 15:48   #11  |  Link
videoh
Useful n00b
 
Join Date: Jul 2014
Posts: 1,667
"has to be fast"

That is vague. It would help if you could specify your performance requirements, say, frame rate for 1080p.

Last edited by videoh; 3rd April 2019 at 16:21.
videoh is offline   Reply With Quote
Old 3rd April 2019, 16:06   #12  |  Link
stax76
Registered User
 
stax76's Avatar
 
Join Date: Jun 2002
Location: On thin ice
Posts: 6,837
Currently I use GDI+, I've not measured it but it's so slow that it hurts, on a HD screen it's OK but with UHD it's maybe 2-3 fps only, anything faster than that would be an improvement.
stax76 is offline   Reply With Quote
Old 3rd April 2019, 16:12   #13  |  Link
videoh
Useful n00b
 
Join Date: Jul 2014
Posts: 1,667
That's horrible.

DGIndexNV uses the simple SetDIBitsToDevice() and plays UHD way, way faster than 2-3 fps. DGIndex also uses that function. Source code for DGIndex is available. See store.cpp.

Use StretchDIBits() if you need to resize for display.

Last edited by videoh; 3rd April 2019 at 16:38.
videoh is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:07.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.