Click to See Complete Forum and Search --> : treeview add nodes


zaryk
April 23rd, 2008, 01:29 PM
hey, im learning win api, and im trying to add nodes to a treeview....this is what i have so. I have found a couple of sites that show how this is done, but I can't ever get them implemented without just out right taking the whole thing and adding it to my code. Any ideas thanks. Along with this, I was hoping someone could lead me to the equivalent of c# .net framework:

1. how to maximize/minimize with button click
2. panels
3. docking
4. how to get rid of the top bar that the window title and close, maximize, and minimize, sit on.



int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPSTR, int)

{
MSG msg;
HWND myDialog = CreateWindowEx(0,
WC_DIALOG,
NULL,
WS_BORDER | WS_VISIBLE,
0,
0,
721,
344,
NULL,
NULL,
NULL,
NULL);

//__________________________________________________

CreateWindowEx(0,
WC_TREEVIEW,
0,
WS_CHILD | WS_VISIBLE,
4,
29,
169,
197,
myDialog,
(HMENU)libTree_id,
NULL,
NULL);

kirants
April 23rd, 2008, 04:18 PM
Wow ! So, what is your question ?
Couple of things:

for C#, this is not the right forum.
Also, it is advisable to ask one question per thread as much as possible when the questions are unrelated

zaryk
April 23rd, 2008, 05:34 PM
oh, Im sorry, well basically im looking to convert part of a c# .net framework program I have to c++ win api....thats why i came here because I am doing the programming in c++ win api, not c#. But, first of all, I would like help on adding nodes to the treeview. In the program it brings up a place for the treeview, but I don't know how to add nodes to it. I didn't want to do this but its not much so here is everything I have. Any links would be good too? Plus, because all my question relate to the same program, wouldn't they be related....lolol....yeah, I know what you mean.

and by the way, im using dev c++

// link libcomctl32.a
//link libwinmm.a

#include <windows.h>
#include <string>
#include <commctrl.h>

int libTree_id = 0;
int compactApp_id = 2;
int minimizeApp_id = 4;
int maximizeApp_id = 6;
int closeApp_id = 8;
int songPlay_id = 10;

LRESULT WINAPI myProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if(message == WM_CLOSE){
PostQuitMessage(0);
}


//_________________________________________________

//_________________________________________________

switch (message)
{
case WM_COMMAND:
{
if(LOWORD(wParam)==compactApp_id){
MessageBox(hwnd,"button has been clicked","Message title",0);
}

if(LOWORD(wParam)==minimizeApp_id){
MessageBox(hwnd,"button has been clicked","Message title",0);
}

if(LOWORD(wParam)==maximizeApp_id){
MessageBox(hwnd,"button has been clicked","Message title",0);
}

if(LOWORD(wParam)==closeApp_id){
PostQuitMessage(0);
}

if(LOWORD(wParam)==songPlay_id){

//load audio and (in short) name it 'myFile'
mciSendString("open \"C:\\Documents and Settings\\zaryk\\My Documents\\My Music\\Revelations.wma\" type mpegvideo alias myFile", NULL, 0, 0);

//play audio

mciSendString("play myFile", NULL, 0, 0);

}
}
break;
case WM_INITDIALOG:
{
InitCommonControls(); // make our tree control to work

}
break;
}
return 0;

}




int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPSTR, int)

{
MSG msg;
HWND myDialog = CreateWindowEx(0, WC_DIALOG, "", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
0, 0, 721, 344, NULL, NULL, NULL, NULL);

CreateWindowEx(0,
WC_TREEVIEW,
NULL,
WS_CHILD | WS_VISIBLE,
4,
29,
169,
197,
myDialog,
(HMENU)libTree_id,
NULL,
NULL);

//=================================================================

CreateWindowEx(0, "BUTTON", "", BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD,
234, 281, 42 , 23, myDialog, NULL,NULL,NULL);

CreateWindowEx(0, "BUTTON", "", BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD,
282, 281, 42 , 23, myDialog, NULL,NULL,NULL);


CreateWindowEx(0, "Button", "Play", BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD,
330, 274, 50 , 37, myDialog, (HMENU)songPlay_id,NULL,NULL);
//__________________________________________
//create the button
//0 -
//"Button" - note this second argument - class name
//"My Button" - Window Title
//BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD - push button specific style - child of the parent window
//- drawn on parent window
//50, 50, 100, 25 - size of button
//NULL
//NULL
//NULL
//__________________________________________

CreateWindowEx(0, "BUTTON", "", BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD,
386, 281, 42 , 23, myDialog, NULL,NULL,NULL);

CreateWindowEx(0, "BUTTON", "", BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD,
434, 281, 42 , 23, myDialog, NULL,NULL,NULL);

// Custom Control Box

CreateWindowEx(0, "BUTTON", "", BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD,
600, 0, 21 , 23, myDialog, (HMENU)compactApp_id,NULL,NULL);

CreateWindowEx(0, "BUTTON", "", BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD,
633, 0, 21 , 23, myDialog, (HMENU)minimizeApp_id,NULL,NULL);

CreateWindowEx(0, "BUTTON", "", BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD,
660, 0, 21 , 23, myDialog, (HMENU)maximizeApp_id,NULL,NULL);

CreateWindowEx(0, "BUTTON", "", BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD,
687, 0, 21 , 23, myDialog, (HMENU)closeApp_id,NULL,NULL);



//End Custom Control Box

SetWindowLong( myDialog, DWL_DLGPROC, (long) myProc );
//___________________________________________________________
//now set the procedure
// handle of the window we are attaching procedure to
//dialog window specific attribute - the dialog procedure
//name of procedure
//___________________________________________________________


while(GetMessage(&msg,NULL,0,0)) {

TranslateMessage(&msg);
DispatchMessage(&msg);

}
return 0;

}

kirants
April 23rd, 2008, 05:37 PM
Your first stop should be:
http://msdn2.microsoft.com/en-us/library/aa921604.aspx

zaryk
April 23rd, 2008, 05:50 PM
Thanks for a quick reply. Thats going to explain alot......I was on the site before, but apparently looking in the wrong area.