Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 29th, 2005, 5:09 PM   #1
brokenhope
Hobbyist Programmer
 
Join Date: Apr 2005
Posts: 126
Rep Power: 4 brokenhope is on a distinguished road
Question about Win32 Programming

-First im mixed up with what win32 means, when you refer to win32 programming does it mean application gui programming? or just programming with c++ in general, including dos like apps?

-2nd when I program and I have gui, and im making real applications with windows, the style seems a little... diffrent (im use to including iostream and using cout and stuff and making dos applications, but it doesnt seem like its that way when im using win32 programming and making real windows and stuff) so is there any diffrences or what?
brokenhope is offline   Reply With Quote
Old Apr 29th, 2005, 7:06 PM   #2
iignotus
Professional Programmer
 
iignotus's Avatar
 
Join Date: Apr 2005
Location: Nowhere Special
Posts: 466
Rep Power: 4 iignotus is on a distinguished road
Send a message via AIM to iignotus
1st -- Win32 just means programming for 32-bit Windows Operating Systems. However, since Windows-specific programming often has to do with GUI creation, the term can sometimes be used to mean that, specifically, instead.

2nd -- Windows programming relies on its own structuring and API (application programming interface), including its own ways to send data to one window or receive user input. Is that what you mean?
__________________
% rc4 hexkey < input > output
#define S ,t=s[i],s[i]=s[j],s[j]=t /* rc4 hexkey <file */
unsigned char k[256],s[256],i,j,t;main(c,v,e)char**v;{++v;while(++i)s[ 
i]=i;for(c=0;*(*v)++;k[c++]=e)sscanf((*v)++-1,"%2x",&e);while(j+=s[i]
+k[i%c]S,++i);for(j=0;c=~getchar();putchar(~c^s[t+=s[i]]))j+=s[++i]S;}
iignotus is offline   Reply With Quote
Old Apr 29th, 2005, 7:38 PM   #3
brokenhope
Hobbyist Programmer
 
Join Date: Apr 2005
Posts: 126
Rep Power: 4 brokenhope is on a distinguished road
Umm yea I think so, so would making command prompt like programs with the iostream be win32 programing? Im guessing not but im just making sure...
brokenhope is offline   Reply With Quote
Old Apr 29th, 2005, 8:10 PM   #4
iignotus
Professional Programmer
 
iignotus's Avatar
 
Join Date: Apr 2005
Location: Nowhere Special
Posts: 466
Rep Power: 4 iignotus is on a distinguished road
Send a message via AIM to iignotus
I wouldn't think so, only due to the fact that iostream is a cross-platform library. If you used a Windows-only library to do programming, even console programming, that (I believe) would make it Win32 programming. Not just GUI.
__________________
% rc4 hexkey < input > output
#define S ,t=s[i],s[i]=s[j],s[j]=t /* rc4 hexkey <file */
unsigned char k[256],s[256],i,j,t;main(c,v,e)char**v;{++v;while(++i)s[ 
i]=i;for(c=0;*(*v)++;k[c++]=e)sscanf((*v)++-1,"%2x",&e);while(j+=s[i]
+k[i%c]S,++i);for(j=0;c=~getchar();putchar(~c^s[t+=s[i]]))j+=s[++i]S;}
iignotus is offline   Reply With Quote
Old Apr 29th, 2005, 8:37 PM   #5
brokenhope
Hobbyist Programmer
 
Join Date: Apr 2005
Posts: 126
Rep Power: 4 brokenhope is on a distinguished road
Ah thanks, my next question is a bit of opinion based, but im working on a notepad type program, just to get me started with making a interface based program. Its programmed with win32 programming. A few things I want to include in it is a syntax highlighter (which I dont even know the base of one, I mean I dont know whats highlighted and what color). Another thing I want to include is an abbreviation system, and a insert header. The abbreviation system is so you can type special things and it will turn it into what it abbreviates, for instance {!!UP!!} could be an abbreviation for 2 line function that uploads that gets tiresome to retype. The insert header is to insert preformatted headers into the project to copywrite it or whatever. Would doing those "typing" depended features be hard to add in? or are they something that should be for more experienced programmers? (Since im still pretty new)
brokenhope is offline   Reply With Quote
Old Apr 29th, 2005, 9:51 PM   #6
iignotus
Professional Programmer
 
iignotus's Avatar
 
Join Date: Apr 2005
Location: Nowhere Special
Posts: 466
Rep Power: 4 iignotus is on a distinguished road
Send a message via AIM to iignotus
That abbreviation thing sounds like a macro library or somewhat like a code-completion library. That should be very easy to implement. The insert-header function sounds like it would be pretty easy to implement, as well. The syntax highlighter is pretty much up to you, what you want to make bold/italic/underlined and what colors you want to make each keyword. That's probably the hardest thing to implement, only because it seems like the most tedious to do.

I have had considerable GUI programming experience; however, with wxWidgets (and FOX and FLTK...) instead of the Windows-only API. I will try to help you as best I can with any questions. These things you want to do, to me, seem like a very good direction to go to. They are challenging for a beginner, yet not impossible. I suggest pursuing each of them in you notepad-type application.
__________________
% rc4 hexkey < input > output
#define S ,t=s[i],s[i]=s[j],s[j]=t /* rc4 hexkey <file */
unsigned char k[256],s[256],i,j,t;main(c,v,e)char**v;{++v;while(++i)s[ 
i]=i;for(c=0;*(*v)++;k[c++]=e)sscanf((*v)++-1,"%2x",&e);while(j+=s[i]
+k[i%c]S,++i);for(j=0;c=~getchar();putchar(~c^s[t+=s[i]]))j+=s[++i]S;}
iignotus is offline   Reply With Quote
Old Apr 30th, 2005, 1:48 PM   #7
brokenhope
Hobbyist Programmer
 
Join Date: Apr 2005
Posts: 126
Rep Power: 4 brokenhope is on a distinguished road
Alright thanks, im probably going to have a few questions about it when I get to that point, Im following a tutorial to get most of it done, but I cant go any farther because I have to include 2 .rc files, and gay dev-c++ is messed up and the project window cuts off the Ok and Cancle buttons so I can only use the 1 resource file all projects use by default and change that around >_< I hate dev-c++'s crappy interface, ive tried downloading ms visual c++ but I cant get it to download anywhere, and I have visual c++ 2005 express edition, but I cant get it to work, I cant even figure out to make real apps, the only option I get in the "Win32" category for projects is console application, and it looks like it makes dos things. So any suggestion for a compiler that will work?
brokenhope is offline   Reply With Quote
Old Apr 30th, 2005, 1:59 PM   #8
iignotus
Professional Programmer
 
iignotus's Avatar
 
Join Date: Apr 2005
Location: Nowhere Special
Posts: 466
Rep Power: 4 iignotus is on a distinguished road
Send a message via AIM to iignotus
Well, I believe I know the problem you're having with Dev-C++. I use it. It is a great compiler, but a shitty form creator. I don't know why, but it is. I suggest completely forgoeing the form manager, and doing things by hand. It'll make life a lot easier and more controlled in the end, at the expense of a higher learning curve.

Keep Dev-C++, it's the only good IDE/compiler set out there that's also free. But try not to use the form managers, they've done nothing but mess up for me as well.
__________________
% rc4 hexkey < input > output
#define S ,t=s[i],s[i]=s[j],s[j]=t /* rc4 hexkey <file */
unsigned char k[256],s[256],i,j,t;main(c,v,e)char**v;{++v;while(++i)s[ 
i]=i;for(c=0;*(*v)++;k[c++]=e)sscanf((*v)++-1,"%2x",&e);while(j+=s[i]
+k[i%c]S,++i);for(j=0;c=~getchar();putchar(~c^s[t+=s[i]]))j+=s[++i]S;}
iignotus is offline   Reply With Quote
Old Apr 30th, 2005, 2:25 PM   #9
brokenhope
Hobbyist Programmer
 
Join Date: Apr 2005
Posts: 126
Rep Power: 4 brokenhope is on a distinguished road
How can I include the .rc files by hand? I never knew you could.

I just tried

#pragma resource "notepadresource.rc"

and I dont get an error but it doesnt seem to link it either 0_o...

Hmm I found how to do it with the project manager, since navigating throuh the areas by pressing tab, usually they all go in order, but in dev-c++ it jumps around, so it took awhile to found which hidden amount of hitting tabs would finally select the ok button, it turned out it was 9, so I just have to press tab 9 times and hit enter and its submitted, really annoying but works .

So far everything im learning is going well, but man this stuff takes a lot of thought... is it bad that I dont have any of this memorised yet? I still dont know any of the syntaxes of functions, or how to create a window or dialog from memory, I always look at previous code for refrence.

Also I wanna know what the styles I can use are, ive searched google for awhile and ive only seen postbits of other peoples codes, not intended to use as a refrence. MSDN just says WS_* and all that stuff, I dont know any of the * though and thats what I wanna know. Heres what I mean, I have:

STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION

And I want to change its style (its dialogex) the thing im intending to do is make it overlap the window, so it doesnt go behind it when you click somewhere other than the diologe box. But knowing all I can use would be more helpful ^_^.

Last edited by brokenhope; Apr 30th, 2005 at 10:02 PM.
brokenhope is offline   Reply With Quote
Old May 1st, 2005, 3:46 PM   #10
brokenhope
Hobbyist Programmer
 
Join Date: Apr 2005
Posts: 126
Rep Power: 4 brokenhope is on a distinguished road
Ok now I really need help, ive gotten everything designed in the abbriviation dialog, and so far most of the stuff is working (remove and add). But now heres what I have to do:

- Make it so abbrivating for is associated with abbriviation, which I think I did already correctly, I just cant get the code to read any of it to work (I dont even know how to do it ive just been messing around with stuff)
- Make it so when you click something in the list it sets IDC_TEXT1 (abbriviation) and IDC_TEXT2 (abbriviating) to there values in the textbox.

Theres still more but this is all im having trouble with at this point.

To start off heres the whole dialog code:

// Dialog Abbreviation Manager
BOOL CALLBACK DialogABBR(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
  // Define Global Variables
  HWND hList = GetDlgItem(hwnd, IDC_LIST);
  HWND bRemove = GetDlgItem(hwnd, IDC_REMOVE);
  HWND bEdit = GetDlgItem(hwnd, IDC_EDIT);

    switch(Message)
    {
        case WM_INITDIALOG:
 			SetDlgItemText(hwnd, IDC_TEXT1, "Abbriviation");
            SetDlgItemText(hwnd, IDC_TEXT2, "Abbriviation For");
            return TRUE;
        break;
        case WM_COMMAND:
            switch(LOWORD(wParam))
            {
                case IDC_CANCEL:
                    EndDialog(hwnd, IDCANCEL);
                break;


                case IDC_LIST:
                {
                    // It's our listbox, check the notification code
                    switch(HIWORD(wParam))
                    {
                        case LBN_SELCHANGE:  // Something is selected / Selection Changes
                        {
                                // Check to see if you set value in boxes
                               	int count = SendMessage(hList, LB_GETSELCOUNT, 0, 0);
                                    if(count == 1) {
									    int index;
									    int err = SendMessage(hList, LB_GETSELITEMS, (WPARAM)1, (LPARAM)&index);
									        if(err != LB_ERR)
								         	{
										    // Get the data we associated with the item above
									     	// What it abbriviates
                							int i;
                                            int *buf = (int*)GlobalAlloc(GPTR, sizeof(int) * count);
                                            char* buffer1 = buf[i];
                                            MessageBox(hwnd, buffer1, "Notice", MB_OK);
                                            // buf1 = (char*)GlobalAlloc(GPTR, len + 1);
										    // char* data = SendMessage(hList, LB_GETITEMDATA, (WPARAM)index, 0);
  			                                // SetDlgItemText(hwnd, IDC_TEXT2, data, FALSE);
									        }
                                    }
                                if(!(EnableWindow(bRemove, true)) && !(IsWindowEnabled(bRemove))) {
                                MessageBox(hwnd, "Error, Unable to enable remove button", "Notice", MB_OK | MB_ICONINFORMATION);
                                }
                                if(!(EnableWindow(bEdit, true)) && !(IsWindowEnabled(bEdit))) {
                                MessageBox(hwnd, "Error, Unable to enable edit button", "Notice", MB_OK | MB_ICONINFORMATION);
                                }
                        }
                        break;
                    }
                }
                break;

                case IDC_REMOVE:  // Hit Remove Button
                {
					int count = SendMessage(hList, LB_GETSELCOUNT, 0, 0);
                        if(count != 0) {
                        // Only want to do something if more than 0 is selected
                        // Allocate memory for selected items
                        int i;
                        int* buf;
    	                buf = (int*)GlobalAlloc(GPTR, sizeof(int)*count);
           		     	SendMessage(hList, LB_GETSELITEMS, (WPARAM)count, (LPARAM)buf);
		                // Now we loop through the list and remove each item that was
				        // selected.

				        // WARNING!!!
				        // We loop backwards, because if we removed items
		     	        // from top to bottom, it would change the indexes of the other
	     		    	// items!!!
       					    for(i = count - 1; i >= 0; i--)
		   					{
	    		          	SendMessage(hList, LB_DELETESTRING, (WPARAM)buf[i], 0);
				            }
                        GlobalFree(buf);
                            if(EnableWindow(bRemove, false)) {
                            MessageBox(hwnd, "Error, Unable to disable remove button", "Notice", MB_OK | MB_ICONINFORMATION);
                            }
                            if(EnableWindow(bEdit, false)) {
                            MessageBox(hwnd, "Error, Unable to disable edit button", "Notice", MB_OK | MB_ICONINFORMATION);
                            }
                    }
                }
                break;

                case IDC_ADD:  // Hit add button
                {
                    // Find out how long the string is to allocate memory
                    int len = GetWindowTextLength(GetDlgItem(hwnd, IDC_TEXT1));
          			if(len > 0)
					{
						// Now we allocate, and get the string into our buffer
						int i;
						char* buf;
                        char* buf2;
						buf = (char*)GlobalAlloc(GPTR, len + 1);
                        buf2 = (char*)GlobalAlloc(GPTR, len + 1);
						GetDlgItemText(hwnd, IDC_TEXT1, buf, len + 1);
                        GetDlgItemText(hwnd, IDC_TEXT2, buf2, len + 1);


                        // Send the item to the list

                        int index = SendDlgItemMessage(hwnd, IDC_LIST, LB_ADDSTRING, 0, (LPARAM)buf);
                       	SendDlgItemMessage(hwnd, IDC_LIST, LB_SETITEMDATA, (WPARAM)index, (LPARAM)buf2);
                        GlobalFree((HANDLE)buf); // Free the memory
                     }
                }

                break;
                case IDOK:
                    EndDialog(hwnd, IDOK);
                break;
                case IDCANCEL:
                    EndDialog(hwnd, IDCANCEL);
                break;
            }
        break;
        default:
            return FALSE;
    }
    return TRUE;
}

Since I doubt you want to look through all of it, Ill just give you the function that im having trouble with

                                    if(count == 1) {
									    int index;
									    int err = SendMessage(hList, LB_GETSELITEMS, (WPARAM)1, (LPARAM)&index);
									        if(err != LB_ERR)
								         	{
										    // Get the data we associated with the item above
									     	// What it abbriviates
                							int i;
                                            int *buf = (int*)GlobalAlloc(GPTR, sizeof(int) * count);
                                            char* buffer1 = buf[i];
                                            MessageBox(hwnd, buffer1, "Notice", MB_OK);
                                            // buf1 = (char*)GlobalAlloc(GPTR, len + 1);
										    // char* data = SendMessage(hList, LB_GETITEMDATA, (WPARAM)index, 0);
  			                                // SetDlgItemText(hwnd, IDC_TEXT2, data, FALSE);
									        }
                                    }

Where theres 3 things commented out in a row is where I was working. I cant get this to work. If theres anything else you need just tell me. But I cant figure out how to size the variable correctly, and put the values in it, then output in a messagebox (which is just for test, really in the end it will be changing the text in the editboxes)

Sorry for the code messyness, I hate dev-c++'s idea of "autostructuring" code for you with a burning pation, it doesnt help at all I spend more time trying to get the stupid things to tab out evenly than they did developing the stupid feature... well probably not, but I spend a lot of time having to organize it, and its impossible to keep the code organized with it.

Last edited by brokenhope; May 1st, 2005 at 3:49 PM.
brokenhope is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:51 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC