William Hemsworth 1,339 Posting Virtuoso

I would definetely say Flash AS2. The absolute most important part is that the students are motivated, and flash allows you to be very creative with just a basic knowledge of math. I got into programming through AS2 when I was about 12, and then started C++ a year later, which to my surprise had very similar syntax to flash actionscript. AS2 doesn't give annoying errors which will put off students, its flexible, and good practice. Since then, I've had a passion for programming because I see it as a form of art, not just a school subject.

Having now started at university, many people who have never programmed before are being forced to learn programming through dull Java console applications, it takes away the good enthusiasm I usually have when programming.

William Hemsworth 1,339 Posting Virtuoso

If you're using windows, try:

#include <windows.h>
#include <iostream>
using namespace std;

int main() {
  char szFileName[MAX_PATH];
  HINSTANCE hInstance = GetModuleHandle(NULL);
  GetModuleFileName(hInstance, szFileName, MAX_PATH);
  cout << szFileName;
  cin.ignore();
}
William Hemsworth 1,339 Posting Virtuoso

This is a C++ snippet I made a long time ago, it's practically C and with some searching I'm sure you would have found it anyway. It's well commented so it should help you. [link]

William Hemsworth 1,339 Posting Virtuoso

Let Windows handle all that (:

#include <windows.h>
#include <shlobj.h>
#include <iostream>

int main() {
  char appDataPath[MAX_PATH] = { 0 };

  SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, appDataPath);
  std::cout << appDataPath;
}
William Hemsworth 1,339 Posting Virtuoso

I've started mixing words together that i can easily remember for my passwords. Pretend my house alarm code is 7142, and my college username is WILLH, mix them together and:

7  1  4  3
 W  I  L  L  H
---------------
7W1I4L3LH

It looks pretty secure, and if you ever forget it, you can figure it out again in a minute or so.

William Hemsworth 1,339 Posting Virtuoso

Has anybody seen that 2012 movie?

Yep, it's pretty good, quite long though.

William Hemsworth 1,339 Posting Virtuoso

What are these DEBUG and UNICODE? Can you give me an example?

If the compiler is set up to produce a debug executable (to allow the programmer to debug the program easier), then there's more information and instructions packed into the executable which would increase its size.

UNICODE is a type of character, normally a character in C++ is one byte, but if UNICODE is defined, then you would be using a two byte characters (capable of holding thousands more characters to support chinese and other types of symbols.

By resource files, do you mean to say header files?

By resource files, I mean files with the .res extensions which allow you to internally attach files such as images or videos into the executable. Nothing to do with header files.

The file size is dependant on so many things, If i statically link all the applications dependencies, then the program can turn from 10kb to 60kb.

William Hemsworth 1,339 Posting Virtuoso

And if you include 'resource files' to your application, the size will go up about the size of the files you include in it. As AD said, it's very often different because of the compiler and settings.

William Hemsworth 1,339 Posting Virtuoso

You could just use the free Microsoft Visual C++ Compiler / IDE, it comes with everything together. [link]

William Hemsworth 1,339 Posting Virtuoso

Sure, but I get the feeling you didn't search first. Try this:

#include <iostream>
#include <direct.h>
using namespace std;

int main() {
  _mkdir("C:\\My Directory");
}
William Hemsworth 1,339 Posting Virtuoso

It has to be this compiler being buggy or something.

Just because it doesn't work, doesn't mean the compiler has a bug. I changed it, and it worked. I just used the resource code from another project which had a auto-generated resource file.

There's one easy fix for all this, just don't do it manually :icon_lol:

William Hemsworth 1,339 Posting Virtuoso

you've forgotten to include "resource.h"..

I'm pretty confident that's not how it works, the preprocessor just replaces #include "resource.h" with the content of the file anyway. I think it's something to do with your resource file code, it seems quite different to what's generated by the Resource Editor.

William Hemsworth 1,339 Posting Virtuoso

When you get into problems with resources like this, just start over, it saves yourself trouble in the long run. Also, use a resource Viewer/Editor if possible, it prevents these sort of problems.

William Hemsworth 1,339 Posting Virtuoso

I'm afraid the code is correct :)
The problem is a compiler setting, make sure the project is a "Windows Application".

And if you seriously can't figure out the compiler option (and you're using VC++), add this line of code to the very start of your program.

#pragma comment(linker, "/SUBSYSTEM:WINDOWS")
William Hemsworth 1,339 Posting Virtuoso

The easy way, at the very start of your code, add this line:

#pragma comment(lib, "comctl32.lib")
William Hemsworth 1,339 Posting Virtuoso

Yep, nezachem is correct, the prototypes in that header mean nothing if they aren't linked with the right library. Try linking to comctl32.lib.

William Hemsworth 1,339 Posting Virtuoso

The file doesn't need to appear in the solution explorer. Do you know how to work with resource files? You can put any kind of file into a resource file, you just need the right commands to read them.

So, first you need to create a resource file for your project by right clicking on your project name and adding a resource file.

Then double click on your resource file in the solution explorer to open it, then right click on resource.rc and click "Add resource", then press 'Import'.

If you do all those steps right, it will work.

Hope this helps.

William Hemsworth 1,339 Posting Virtuoso

See example code and attachments.

#include <windows.h>
#include "resource.h"
#pragma comment(lib,"Winmm.lib")

int WINAPI WinMain(
      HINSTANCE hInstance,
      HINSTANCE hPrevInstance,
      LPSTR lpCmdLine,
      int nShowCmd)
{
  PlaySound( (char*)IDR_WAVE1, NULL, SND_RESOURCE | SND_ASYNC ); 
  MessageBox( NULL, "", "", MB_OK );
  return 0;
}
William Hemsworth 1,339 Posting Virtuoso

Well, to use that line of code, the .wav file has to be in the same directory as the executable/project folder if you're running directly from Visual Studio. If you want to attach it to your resouce file, that's easy too.

William Hemsworth 1,339 Posting Virtuoso

You forgot the SND_FILENAME argument, change that line to:

PlaySound((LPCWSTR)"tone.wav", 0, SND_LOOP|SND_ASYNC|[B]SND_FILENAME[/B]);

and it should work.

Carrots commented: Thanks for the help :) +1
William Hemsworth 1,339 Posting Virtuoso

Not sure, but does this work?

Datetime^ curDate = gcnew Datetime();
curDate = DateTime::Now;
William Hemsworth 1,339 Posting Virtuoso

Yep, almost all spaces (except those between keywords) are ignorable, so in the end the compiler would just see it as

int*a

anyway.

William Hemsworth 1,339 Posting Virtuoso

So you want to swap keys around, for example the user presses 'INSERT', 'A' is pressed instead? You don't need to use SendInput, it's much simpler to use keybd_event, so you can change that case to:

case VK_INSERT:
  {
      whichbuttonpressed = 1;
      cout << "hey you this is insert \n\n";
      keybd_event( 'A',0,0,0 );
      return 1;
  }

Other than that, I'm not entirely sure what it is you're asking for.

William Hemsworth 1,339 Posting Virtuoso

Misread the question, but that's still a great way to detect keypresses, the rest shouldn't be hard.

William Hemsworth 1,339 Posting Virtuoso

Really not the best way to detect keystrokes, I'd suggest a Windows hook, because you can actually change what the output of that key will be. For example, here's how you could turn the Space bar into the Return Key.

#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <iostream>
using namespace std;

LRESULT CALLBACK keyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam) {
	PKBDLLHOOKSTRUCT p = (PKBDLLHOOKSTRUCT) (lParam);
  if (wParam == WM_KEYDOWN) {
		switch (p->vkCode) {
      case VK_SPACE:
        {
          // Space pressed

          // Press ENTER instead
          keybd_event( VK_RETURN, 0, 0, 0 );

          // Dont let windows process SPACE
          return 1;
        }
        break;
    }
  }
  return CallNextHookEx(NULL, nCode, wParam, lParam);
}

int main() {
  // Set windows hook
  HHOOK keyboardHook = SetWindowsHookEx(
      WH_KEYBOARD_LL,
      keyboardHookProc,
      GetModuleHandle( 0 ),
      0);

  MSG msg;
  while ( GetMessage(&msg, NULL, 0, 0) > 0 ) {
    TranslateMessage( &msg );
    DispatchMessage( &msg );
  }
}

Hope this helps.

William Hemsworth 1,339 Posting Virtuoso

Good (: You can flag the thread as solved at the bottom.

William Hemsworth 1,339 Posting Virtuoso

Tried both ways It doesn't save anything to the output file :(. It is completely blank.

I edited my post maybe before you tried that code, try again. There's no reason why that function shouldn't work, if it still doesn't work, show me the code you're using.

William Hemsworth 1,339 Posting Virtuoso

Either turn UNICODE off, or change the code to:

#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <iostream>
#include <fstream>

void saveCaption(HWND hwnd, TCHAR *filename) {
  int length = GetWindowTextLength( hwnd ) + 1;
  TCHAR *caption = new TCHAR[length];

  GetWindowText( hwnd, caption, length );

  std::wofstream out( filename );
  out << caption;

  delete[] caption;
}

int main() {
  saveCaption( GetConsoleWindow(), TEXT("caption.txt") );
}
William Hemsworth 1,339 Posting Virtuoso

Wouldn't usually give away code, but it's just so small.

#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <iostream>
#include <fstream>

void saveCaption(HWND hwnd, char *filename) {
  int length = GetWindowTextLength( hwnd ) + 1;
  char *caption = new char[length];

  GetWindowText( hwnd, caption, length );

  std::ofstream out( filename );
  out << caption;

  delete[] caption;
}

int main() {
  saveCaption( GetConsoleWindow(), "caption.txt" );
}
William Hemsworth 1,339 Posting Virtuoso

Check variables that you allocated memory on, and make sure you deleted it somewhere else in the code. If you forget to free any memory, that's a memory leak.

William Hemsworth 1,339 Posting Virtuoso

I think the number of active users has always been fairly low, for example at the moment the only people I see regularly in the list are:


Most of the rest will ask their question, and never come back. Some may return a few more times, but very few actually stay.

And yep, call of duty's been released :icon_cheesygrin:

William Hemsworth 1,339 Posting Virtuoso

Perhaps the PlaySound function?

PlaySound("H:\\sissys.mp3", NULL, SND_FILENAME);
William Hemsworth 1,339 Posting Virtuoso

If it's the default tab-control, then your event handler should look somewhat like this:

case WM_NOTIFY:
      {
        HWND tabs = GetDlgItem(hDlg, IDC_TABS);
        switch ( ((LPNMHDR)lParam)->code ) {
          case TCN_SELCHANGE:
            {
              selectedTab = TabCtrl_GetCurSel( tabs );
              // Code here
            }
            break;
        }
      }
      break;

But looking through your resource code, I don't see any sign of a SysTabControl32 box, what are you using for your tabs?

William Hemsworth 1,339 Posting Virtuoso

How can I say, if the tab button is pushed, use SetFocus() ?

Show me your code.

Have you already programmed the functionality of the tabs? and do you have a HWND of the text box? If not, these are small details I can still help with.

William Hemsworth 1,339 Posting Virtuoso

If you use SetFocus on the handle to the text box, it should move the text cursor to there.
Just tried it, it worked.

William Hemsworth 1,339 Posting Virtuoso

Have you tried SetFocus?

William Hemsworth 1,339 Posting Virtuoso

Same here.. I spend most of the night on here :)

But then I work graveyard shift in a very quiet callcenter so I have plenty of time to be bored :)

I also have done some photography, although not recently.. some of it is still up at http://stuff.elvenblade.com/camera if anyone is interested.

Make a few friends in china so you have people to talk to :) Also, you have some pretty neat photos there, with a little bit of touching, they could be even nicer. Like this into this.

William Hemsworth 1,339 Posting Virtuoso

That is an expensive camera

Sure is, combining my own money and christmas to be able to afford it. After that, the next step is to save up for [link].
What an expensive hobby :idea:

William Hemsworth 1,339 Posting Virtuoso

William, great pictures. I especially like the Lighting up the Path pic. They look very professional. Keep up the good work.
Also, good luck with piano. Learning an instrument takes lots of patience and practice.

Why thanks :) I'll be getting this camera soon [link], I can't wait. Those pictures were taken with my awful Samsung S570, it will be nice to use a real camera for once.

William Hemsworth 1,339 Posting Virtuoso

If i am that bored i go and garden. Or practice piano

Sounds good :) I'll be starting piano lessons soon, expensive though. When I'm bored, I'll try something new, for example i've started getting into photography now, here are some I've taken fairly recently.

Why do people limit themselves to the PC only sometimes? :icon_lol:

William Hemsworth 1,339 Posting Virtuoso

That's not correct, that just turns into:

#include <stdio.h>

int main() {
    printf("%s","string");
    return (0);
}

Once the preprocessor's done.

William Hemsworth 1,339 Posting Virtuoso

Ahh, that's C+ code, didn't realize which forum this was. Try this:

#include <stdio.h>

int main() {
  printf("Hello"),
  getchar();
  return 0;
}
William Hemsworth 1,339 Posting Virtuoso

Here the statement finishes with a comma, not a semicolon:

#include <iostream>

int main() {
  printf("Hello"),
  getchar();
  return 0;
}
William Hemsworth 1,339 Posting Virtuoso

An admin will need to do it. And you can only generally change it once.

Mine's been changed twice ;) even if it was only by a letter or two each time.

William Hemsworth 1,339 Posting Virtuoso

Glad to see you got it working :icon_lol:
You're welcome.

William Hemsworth 1,339 Posting Virtuoso

Don't know, if you did everything I said it should have worked.

William Hemsworth 1,339 Posting Virtuoso

You're missing two sets of end curly braces, change the end to this:

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
                  form2 ^secondForm = gcnew form2();
                  this->Hide();
                  secondForm->Show();
            }
      };
}

Try to keep your formatting tidy, hope this helps.

William Hemsworth 1,339 Posting Virtuoso

Could you tell me more exactly in what file and in what place in that file I should copy that code? Or just what event handler is?

When you double click your button in designer mode, it takes you to the code that's executed once it's pressed, It would look something like this:

private: System::Void mybutton_Click(System::Object^  sender, System::EventArgs^  e) {
    Form2 ^secondForm = gcnew Form2();
    this->Hide();
    secondForm->Show();
}
William Hemsworth 1,339 Posting Virtuoso

Looks good to me.

Okay, now at the top up your header file Form1.h, add the code:

#include "Form2.h"

and to hide the current form and open the new one, place this code in the event handler of the Next button on Form1:

Form2 ^secondForm = gcnew Form2();
this->Hide();
secondForm->Show();

Be weary, one of your forms is named form1 and the other Form2, remember C++ is case sensitive.

William Hemsworth 1,339 Posting Virtuoso

If it didn't allow you, that's because its probably already been taken. Try the same name slightly changed, for example, you would probably find Assim2 works, but be creative.