Friday, April 4, 2008
Database
Finally, today I got the data from my database displayed in my window where I want it to be displayed. But. I can't make it display in the actual program, just in a simplest odbc application. When I create a simple database with one table and a simple table with corresponding controls, everything works just perfectly. But when I try to use my database, which contains multiple tables and all of my controls, it just doesn't want to display them. In fact, it doesn't even want to run or debug the application. It might be because of the structure of the database, or relationships between tables, or I don't know. Maybe I'll just start it all again from scratch.
Thursday, March 27, 2008
odbc
Ok so I decided to switch to ODBC instead of DAO, as it seems to perform all the same functions, and it actually works. (Well, at least it doesn't give me any errors yet). So I'm just going to try that, and then we'll see. I also can't do much at home, because I don't have microsoft access there, and open office version can't create the mdb files that I need. Anyways, I think I'm getting closer to what I have planned.
Friday, March 21, 2008
Ufff... all that software!
Finally I got to the most interesting part of my program - connecting the c++ program body with the database I have. I found a lot of tutorials on that topic online, especially on microsoft msdn website. Well, as I decided to use mfc in my program (I don't want to code everything by hand), I tried to link the database and my program statically through the mfc wizard. When I tried that I ran into "Unrecognized database format". At first I thought that was because I didn't have Microsoft Access on my computer. So I installed special dao dll libraries. That didn't really work. Then I tried to install free trial of Access, but that didn't help either. Finally, different online programming forums told me to update my MFC library from Jet 3.4 to Jet 4, which I couldn't find for free anywhere. So I found the Visual Studio Service Pack 5. It says in the description that they updated the mfc in there. It takes pretty long time to install this whole thing. So, the software problems took me way more time than actual coding. I'm filling my database with the units I have for now, while the pack is installing. I really hope it will work.
Monday, March 17, 2008
research
Ok, so now I am reading the "Access Database" book (Thanks, Richard!). The book's really good. It explains all the basics of databases and their structure and how they work. It's pretty understandable, although there is a lot of terms in there. I'm hoping to finish the book as soon as possible and start working on the project. I'm going to make some sample easy databases on the way, just to get it better, and I will probably do them in Access for now. I'll figure it out about the software later.
Thursday, March 13, 2008
The Database
So I started learning all the basics of bulding and transferring data from databases. I decided to use Microsoft Access to build the database, because it's going to be pretty simple. In the program I am going to use DAO library, because that's the one that can read data from Microsoft Access files.
Following the advice of online tutorials, at first I figured out how exactly I wanted the database to work. I split the whole list of units into categories, in each category would be a 2d table, where I would paste the numbers, needed to convert from any unit to any other unit. Basically I would have the same list of units on the horizontal menu and the vertical menu. On their intersections I would put the numbers, by which I need to multiply the horizontal unit to get the vertical one.
I don't have access to any programming or database software right now, so I started just researching and going through tutorials on databases. I found a very good website with different units. Oh my god! I never thought there were so many different crazy units in the world and someone actually wrote them down! This is unbelievable! And that is only from one source! There are only 272 different units - that's just for length! How would I do that without a database?
Another thing is, the same unit in different areas is different. Like the US mile would be totally different from the Scottish mile and so on. At first I thought just to write the region in parenthesis, but then I had an idea, what if I could categorize the units not only by the measurement, but by the area, too. I'm not sure how I'm going to do that yet, I guess I'll figure it out when I get to actually building the database.
Anyways, I found out, that my program might not be as small as I thought, I have many ideas of updating it. I need to build the basics at first :)
Following the advice of online tutorials, at first I figured out how exactly I wanted the database to work. I split the whole list of units into categories, in each category would be a 2d table, where I would paste the numbers, needed to convert from any unit to any other unit. Basically I would have the same list of units on the horizontal menu and the vertical menu. On their intersections I would put the numbers, by which I need to multiply the horizontal unit to get the vertical one.
I don't have access to any programming or database software right now, so I started just researching and going through tutorials on databases. I found a very good website with different units. Oh my god! I never thought there were so many different crazy units in the world and someone actually wrote them down! This is unbelievable! And that is only from one source! There are only 272 different units - that's just for length! How would I do that without a database?
Another thing is, the same unit in different areas is different. Like the US mile would be totally different from the Scottish mile and so on. At first I thought just to write the region in parenthesis, but then I had an idea, what if I could categorize the units not only by the measurement, but by the area, too. I'm not sure how I'm going to do that yet, I guess I'll figure it out when I get to actually building the database.
Anyways, I found out, that my program might not be as small as I thought, I have many ideas of updating it. I need to build the basics at first :)
Thursday, February 21, 2008
My new program
Ok. So I started my project itself today. I decided to make a very cool program.
For that, I think I would need to learn about databases. As I need to store a lot of information in kind of a structured way, I think a database wouldn't be a bad idea. I found some online tutorials on those:
http://www.geekgirls.com/databasics_01.htm
I'm going to research that a little. I am still going to use the shaping of windows code, I think it's really cool. I don't know about control arrays, I guess I wouldn't need them as much. But even if I do, I found something interesting today. The member variables that I found once and didn't know what to do with them, could actually serve as a way to establish an array. They are kind of like pointers, but to the controls, and they can be represented as an array, so. That works for me.
For that, I think I would need to learn about databases. As I need to store a lot of information in kind of a structured way, I think a database wouldn't be a bad idea. I found some online tutorials on those:
http://www.geekgirls.com/databasics_01.htm
I'm going to research that a little. I am still going to use the shaping of windows code, I think it's really cool. I don't know about control arrays, I guess I wouldn't need them as much. But even if I do, I found something interesting today. The member variables that I found once and didn't know what to do with them, could actually serve as a way to establish an array. They are kind of like pointers, but to the controls, and they can be represented as an array, so. That works for me.
Tuesday, February 12, 2008
Shaping the windows
I just found this very cool code! I found out that MFC is good of course, but an empty Win32 would be much better, there are so much more opportunities in it. Although I can't see the dialog itself and arrange all the control elements on the form, I can do it through the code.
Therefore, I found a code to actually change the shape of the window. You would only need an original bmp image with a shape. In bmp format, the compiler sees white as blank space, so I can actually draw the shape of my window. I would just need the following code:
And all the other usual code routines.
I also found out I need to include "windows.h" in any windows application I do. There is also a huge code for just creating a new window and showing it on the screen, which I am trying to understand by lines now. It seems not so hard, but really cool!
Therefore, I found a code to actually change the shape of the window. You would only need an original bmp image with a shape. In bmp format, the compiler sees white as blank space, so I can actually draw the shape of my window. I would just need the following code:
BOOL CreateMainWnd(HINSTANCE hInstance)
{
HFONT buttonfont; /*create windows and set fonts*/
hwMain = CreateWindowEx(0,"Window Shaping","Window Shaping", WS_OVERLAPPED,50,50,450,350,0,0,hInstance,0);
hwStatica = CreateWindowEx(0,"Button","Sant Bani",WS_CHILD | WS_VISIBLE | SS_CENTER, 100,88,50,20,hwMain,0,hInstance,0);
hwStaticb = CreateWindowEx(0,"Button","Exit",WS_CHILD | WS_VISIBLE | SS_CENTER, 194,88,50,20,hwMain,0,hInstance,0);
buttonfont = CreateFont(16,0,FW_DONTCARE,FW_DONTCARE,FW_DONTCARE,
FALSE,FALSE,FALSE,ANSI_CHARSET,OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FF_DONTCARE,"Arial");
SendMessage(hwStatica,WM_SETFONT,reinterpret_cast(buttonfont),MAKELPARAM(1, 0));
SendMessage(hwStaticb,WM_SETFONT,reinterpret_cast(buttonfont),MAKELPARAM(1, 0));
SetWindowPos(hwMain,HWND_TOPMOST,50,50,626,374, NULL);
ShowWindow(hwMain,1);
if(!hwMain)
return FALSE;
return TRUE;
}
LRESULT CALLBACK WindowProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam)
{
switch(wMsg) {
case WM_DESTROY:
PostQuitMessage(0); /*destroy window*/
return 0;
break;
case WM_PAINT:
HDC hdcTemp, bpHDC;
PAINTSTRUCT sentinel;
BITMAP bm;
bpHDC = BeginPaint(hwMain, &sentinel);
if(work) /*if its our first time painting, shape the window*/
{
ShowWindow(hwMain,0); /* window not visible until shaped*/
Mold(bpHDC);
ShowWindow(hwMain,1);
}
hdcTemp = CreateCompatibleDC(bpHDC); /*load and bitblt image to our hdc*/
hwBmp = LoadBitmap(hInst,MAKEINTRESOURCE(102));
SelectObject(hdcTemp,static_cast(hwBmp));
GetObject(static_cast(hwBmp),sizeof(bm),&bm);
BitBlt(bpHDC,0,-30,bm.bmWidth,bm.bmHeight,hdcTemp,0,0,SRCCOPY);
DeleteDC(bpHDC); /*delete uneeded objects to free up memory*/
DeleteDC(hdcTemp);
EndPaint(hwMain,&sentinel);
return 0;
break;
case WM_COMMAND:
/*put a couple of buttons there, just for fun*/
if(wParam == BN_CLICKED)
{
if(reinterpret_cast(lParam) == hwStatica)
ShellExecute(NULL, "open", "http://www.santbani.org", NULL, NULL, SW_SHOWNORMAL);
else if(reinterpret_cast(lParam) == hwStaticb)
DestroyWindow(hwMain);
}
return 0;
break;
case WM_LBUTTONDOWN:
SendMessage(hwMain,WM_SYSCOMMAND,SC_MOVE,0); /*tell the window the user wants to move the window*/
break;
default:
return DefWindowProc(hWnd,wMsg,wParam,lParam);
}
return FALSE;
}
And all the other usual code routines.
I also found out I need to include "windows.h" in any windows application I do. There is also a huge code for just creating a new window and showing it on the screen, which I am trying to understand by lines now. It seems not so hard, but really cool!
Subscribe to:
Posts (Atom)