13 Replies - 1005 Views - Last Post: 15 May 2020 - 09:20 PM Rate Topic: -----

#1 thethispointer   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 14-May 20

Help me plan my program please!

Posted 14 May 2020 - 04:22 PM

Okay, so I want to create a Win32 API using C++. I want the first screen seen to be a clickable menu, once advanced there is a back button to return to the main menu. I want the program to communicate with a web server that has a database on it. I want to submit Time Start, Time End, Availability (w/ short note), View Time Inputs as Table sort-able by Date or Time-Spent-On-Job.

Questions:
  • I know that I am going to use Visual Studio 2019, but what packages do I have to download to access Win32 API for development via GUI tools in VS2019?
  • If I were to break this down into a sequntial list it would probably look like: Main Menu, Advance to Time Input, Advance to Time Table, Advance to Availability Screen, Input Time Start/End, Input Availability, Sort List, ...
  • Can I do this communication via web server fairly easily with Win32 API or an associated plug-in, library, or DLL?


Any other help planning this program would be helpful!

Thank you! Have a great day!

Would developing this program in Javascript make communication with a Web Server Database easier?

Is This A Good Question/Topic? 0
  • +

Replies To: Help me plan my program please!

#2 thethispointer   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 14-May 20

Re: Help me plan my program please!

Posted 14 May 2020 - 04:28 PM

https://www.youtube....h?v=8GCvZs55mEM

Here's how I create the basic window.
Was This Post Helpful? 0
  • +
  • -

#3 thethispointer   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 14-May 20

Re: Help me plan my program please!

Posted 14 May 2020 - 04:38 PM

My first mistake is probably a silly one...

#include <windows.h>

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR args, int ncmdshow)
{
	MessageBox(NULL,"Hello","My Friend!",MB_OK);
	return 0;
}


Severity	Code	Description	Project	File	Line	Suppression State
Error	C1083	Cannot open include file: 'windows.h': No such file or directory	ConsoleApplication001	D:\Notepad++\My Programs\ConsoleApplication001\ConsoleApplication001\ConsoleApplication001.cpp	1	
Error (active)	E1696	cannot open source file "windows.h"	ConsoleApplication001	D:\Notepad++\My Programs\ConsoleApplication001\ConsoleApplication001\ConsoleApplication001.cpp	1	
Error (active)	E0065	expected a ';'	ConsoleApplication001	D:\Notepad++\My Programs\ConsoleApplication001\ConsoleApplication001\ConsoleApplication001.cpp	3	
Warning	MSB8003	The WindowsSDKDir property is not defined. Some build tools may not be found.	ConsoleApplication001	C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets	449	


I think I still don't have all the packages downloaded that I need for Win32 Development on Studio 2019.
Was This Post Helpful? 0
  • +
  • -

#4 jimblumberg   User is online

  • member icon

Reputation: 5858
  • View blog
  • Posts: 17,826
  • Joined: 25-December 09

Re: Help me plan my program please!

Posted 14 May 2020 - 04:52 PM

Did you forget to install Visual Studio C++ support?

See this link for more information.

Jim
Was This Post Helpful? 1
  • +
  • -

#5 thethispointer   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 14-May 20

Re: Help me plan my program please!

Posted 14 May 2020 - 05:15 PM

Posted Image

This stuff?
Was This Post Helpful? 0
  • +
  • -

#6 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 7407
  • View blog
  • Posts: 24,987
  • Joined: 05-May 12

Re: Help me plan my program please!

Posted 14 May 2020 - 06:14 PM

What kind of project is that code in? E.g. when you started. Visual Studio, what project type did you select?
Was This Post Helpful? 0
  • +
  • -

#7 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 7407
  • View blog
  • Posts: 24,987
  • Joined: 05-May 12

Re: Help me plan my program please!

Posted 14 May 2020 - 06:20 PM

Your screenshot of what you installed is unreadable on my phone. I'll have to look on my PC later.

Anyway, there shouldn't be anything extra you need you need to download if you installed VS with the C++ Windows desktop developer workload. That should include the Win32 SDK and setup the appropriate environment variables so that VS can find it. The error messages you have above though indicate that VS can't find the SDK.
Was This Post Helpful? 0
  • +
  • -

#8 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 7407
  • View blog
  • Posts: 24,987
  • Joined: 05-May 12

Re: Help me plan my program please!

Posted 14 May 2020 - 06:51 PM

Moving to C/C++ forum...
Was This Post Helpful? 0
  • +
  • -

#9 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 7407
  • View blog
  • Posts: 24,987
  • Joined: 05-May 12

Re: Help me plan my program please!

Posted 14 May 2020 - 07:00 PM

Now that I can read post #5, yes, it looks like you've installed the correct workload: Desktop development with C++. Just double check under the Individual Components that the Windows 10 SDK is also selected to be installed.
Was This Post Helpful? 0
  • +
  • -

#10 thethispointer   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 14-May 20

Re: Help me plan my program please!

Posted 14 May 2020 - 07:05 PM

Severity	Code	Description	Project	File	Line	Suppression State
Error (active)	E0167	argument of type "const char *" is incompatible with parameter of type "LPCWSTR"	ConsoleApplication001	D:\Notepad++\My Programs\ConsoleApplication001\ConsoleApplication001\ConsoleApplication001.cpp	5	
Error (active)	E0167	argument of type "const char *" is incompatible with parameter of type "LPCWSTR"	ConsoleApplication001	D:\Notepad++\My Programs\ConsoleApplication001\ConsoleApplication001\ConsoleApplication001.cpp	5	
Error	C2664	'int MessageBoxW(HWND,LPCWSTR,LPCWSTR,UINT)': cannot convert argument 2 from 'const char [6]' to 'LPCWSTR'	ConsoleApplication001	D:\Notepad++\My Programs\ConsoleApplication001\ConsoleApplication001\ConsoleApplication001.cpp	5	



#include <windows.h>

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR args, int ncmdshow)
{
	MessageBox(NULL,"Hello","My Friend!",MB_OK);
	return 0;
}


A couple things here. I need a second reference on creating a simple window in Win32 API.

Okay, my next step would be to put buttons on the window? Or, should I change the window from a Message Box to some sort of 'Actual Window'?
Was This Post Helpful? 0
  • +
  • -

#11 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 7407
  • View blog
  • Posts: 24,987
  • Joined: 05-May 12

Re: Help me plan my program please!

Posted 14 May 2020 - 10:02 PM

The Windows default is to compile with the UNICODE flag enabled. This has been true since the early 2000's because Windows XP and up is natively Unicode. The problem is the majority of the tutorials on the web are still based on old books and tutorials written in the 1990's where they are compiling code with the ANSI (actually DBCS, but for some reason it ANSI is the name used) flag enabled. Unicode on windows uses 16 bit characters and strings: WCHAR, LPCWSTR, LPSTR, WCHAR *, etc. ANSI compiles with 8 bit characters and strings: CHAR, LPCSTR, LPSTR, char *, etc.

Most people just say, just turn off UNICODE. You won't need it unless you plan on producing a product that will be translated to many languages. I don't agree. What those people don't tell you is that you also pay a performance cost whenever you call the ANSI versions of the Windows API, Windows has to translate your ANSI/DBCS string into a Unicode string by allocating extra memory for that Unicode string, call the natively Unicode API, and then if necessary convert any return values back from UNICODE to ANSI.

I would recommend just using the TEXT() macro around your constant strings, or manually stick in a L before the string so that you have L"Hello" to create a Unicode string.

Instead of learning to program Windows from Youtube videos, I recommend learning from the same book everyone learned from (including the ANSI-ism): Programming Windows by Charles Petzold. Be sure to get the 5th edition which still teaches things using the Win32 API. Later editions teach using WinForms.

And yes, you should switch from using message boxes to using real windows.
Was This Post Helpful? 1
  • +
  • -

#12 thethispointer   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 14-May 20

Re: Help me plan my program please!

Posted 15 May 2020 - 01:53 PM

Posted Image

Someone I know has a copy! Fantastic! For straight up C++ study, and the best (if only) companion to the book shown here would be... Bjarne Stroustrup's textbook and/or C++ textbook?

By the way I have been fortunate enough to take a C++ course at the community college, 3 actually.

This post has been edited by Skydiver: 15 May 2020 - 09:19 PM
Reason for edit:: Removed unnecessary quote. No need to quote the post above yours.

Was This Post Helpful? 0
  • +
  • -

#13 thethispointer   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 14-May 20

Re: Help me plan my program please!

Posted 15 May 2020 - 02:15 PM

Posted Image

but I have a section from the book I need to read even better... and I'll see what I can do...

#include <windows.h>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) {
    MessageBox(NULL, TEXT("Hello, Windows 98!"), TEXT("HelloMsg"), 0);
    return 0;
}


LOL! "Hello Windows 98" so windows forms is more up to date? What the heck?
Was This Post Helpful? 0
  • +
  • -

#14 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 7407
  • View blog
  • Posts: 24,987
  • Joined: 05-May 12

Re: Help me plan my program please!

Posted 15 May 2020 - 09:20 PM

WinForms was up-to-date in the late 90's and early 2000's. WinForms has not reached end-of-life. If you want to learn the modern way to do Windows GUI's WPF, Xamarin, or WinUI are the ways to go.

I personally don't like Stroustrup's Principles and Practices book, but if it's what you've got readily available to you, then use it. Many colleges do.

Please just copy and paste the errors into code tags like you did for post #3 and post #10. Those are much easier to read, specially on small devices like phones.

Also, there is no need to quote the post above yours. Just use the big Reply button or the Fast Reply area.

Anyway, the reason for the linker error regarding being unable to find _main() is because you created a project that is a C++ console application that expects to have main() as the entry point. A Win32 Windows program has WinMain() as its entry point. In other words, you selected the wrong project type when you created your project above. Start over and select the C++ Windows application.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1