Click here to Skip to main content
16,004,944 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionhow to get the executable path in mfc Pin
alexissss24-Aug-03 3:50
alexissss24-Aug-03 3:50 
AnswerRe: how to get the executable path in mfc Pin
includeh1024-Aug-03 4:09
includeh1024-Aug-03 4:09 
GeneralRe: how to get the executable path in mfc Pin
alexissss24-Aug-03 5:41
alexissss24-Aug-03 5:41 
AnswerRe: how to get the executable path in mfc Pin
Kuniva24-Aug-03 11:32
Kuniva24-Aug-03 11:32 
GeneralSave in xml Pin
lxxrya00124-Aug-03 2:35
lxxrya00124-Aug-03 2:35 
GeneralRe: Drawing to canvis and saving Pin
John M. Drescher24-Aug-03 4:26
John M. Drescher24-Aug-03 4:26 
GeneralHelp me to Create Splitter Window Using SDK Pin
HemantR...24-Aug-03 0:22
HemantR...24-Aug-03 0:22 
GeneralRe: Help me to Create Splitter Window Using SDK Pin
skaanji24-Aug-03 2:47
skaanji24-Aug-03 2:47 
There is no MFC like Splitter control in W32API
but you can easy implement it
just take a look at following example:

// splitter.cpp

#include "stdafx.h"
#include "resource.h"
#include <commctrl.h>

HINSTANCE hInst;
TCHAR szTitle[]="Splitter";
TCHAR szWindowClass[]="Splitter";
HWND hWnd;
int nSplitPos=320; // splitter position
HWND hLB1,hLB2;
LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM );
VOID Resize();

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int xPos,yPos;
long fwKeys;

switch( message )
{
case WM_MOUSEMOVE:
xPos = LOWORD(lParam);
yPos = HIWORD(lParam);
fwKeys=wParam;
// receiving WM_MOUSEMOVE we will check if mouse is inside splitter
if(xPos>nSplitPos-2||xPos<nSplitPos+2)
{
SetCursor(LoadCursor(NULL,IDC_SIZEWE));
// if left button is pressed
// set splitter position to mouse x position
if(fwKeys==MK_LBUTTON)
{
SetCapture(hWnd);
RECT rc;
GetWindowRect(hWnd,&rc);
rc.right-=10;
rc.left+=10;
ClipCursor(&rc);// prevent user to drag splitter out of window
nSplitPos=xPos;
// at last resize views
Resize();
}
else
{
ReleaseCapture();
}
}
break;

case WM_LBUTTONDOWN:
xPos = LOWORD(lParam);
yPos = HIWORD(lParam);
if(xPos>nSplitPos-2||xPos<nSplitPos+2)
SetCursor(LoadCursor(NULL,IDC_SIZEWE));
break;

case WM_SIZE:
Resize();
break;
case WM_DESTROY:
PostQuitMessage( 0 );
break;
default:
return DefWindowProc( hWnd, message, wParam, lParam );
}
return 0;
}

VOID Resize()
{
RECT rc;
GetClientRect(hWnd,&rc);

MoveWindow(hLB1,0,0,nSplitPos-2,rc.bottom,TRUE);
MoveWindow(hLB2,nSplitPos+2,0,rc.right-nSplitPos-2,rc.bottom,TRUE);
}


int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow )
{
MSG msg;
hInst = hInstance;
InitCommonControls();

WNDCLASSEX wcex;

wcex.cbSize = sizeof(WNDCLASSEX);

wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_SPLITTER);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
RegisterClassEx(&wcex);

hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
hLB1=CreateWindowEx(0,"LISTBOX",0,
WS_CHILD|WS_VISIBLE|WS_BORDER|LBS_NOINTEGRALHEIGHT,0,0,0,0,hWnd,NULL,hInst,0);
hLB2=CreateWindowEx(0,"LISTBOX",0,
WS_CHILD|WS_VISIBLE|WS_BORDER|LBS_NOINTEGRALHEIGHT,0,0,0,0,hWnd,NULL,hInst,0);
SendMessage(hLB1,LB_INSERTSTRING,-1,(WPARAM)"Listbox1");
SendMessage(hLB2,LB_INSERTSTRING,-1,(WPARAM)"Listbox2");

if( !hWnd ) return FALSE;

ShowWindow( hWnd, nCmdShow );
UpdateWindow( hWnd );
Resize();

while( GetMessage(&msg, NULL, 0, 0) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
return msg.wParam;
}


GeneralProblem with mutex Pin
Artem Moroz23-Aug-03 23:25
Artem Moroz23-Aug-03 23:25 
GeneralRe: Problem with mutex Pin
John M. Drescher24-Aug-03 4:33
John M. Drescher24-Aug-03 4:33 
GeneralRe: Problem with mutex Pin
Michael Dunn24-Aug-03 5:50
sitebuilderMichael Dunn24-Aug-03 5:50 
GeneralRe: Problem with mutex Pin
Artem Moroz24-Aug-03 10:08
Artem Moroz24-Aug-03 10:08 
Generallinking dialog to menu on SDI Pin
coda_x23-Aug-03 21:18
coda_x23-Aug-03 21:18 
GeneralPrinting question Pin
DougW4823-Aug-03 19:27
DougW4823-Aug-03 19:27 
GeneralRe: Printing question Pin
Ryan Binns24-Aug-03 15:20
Ryan Binns24-Aug-03 15:20 
GeneralThe MFC CreateControl() Pin
tongc23-Aug-03 19:04
tongc23-Aug-03 19:04 
GeneralNeed help on how to add a new line to an edit control Pin
Snyp23-Aug-03 17:04
Snyp23-Aug-03 17:04 
GeneralRe: Need help on how to add a new line to an edit control Pin
Tom Archer23-Aug-03 17:56
Tom Archer23-Aug-03 17:56 
Generalquestion about smtp class Pin
Beer2623-Aug-03 17:02
Beer2623-Aug-03 17:02 
GeneralRe: question about smtp class Pin
Alexander M.,24-Aug-03 6:33
Alexander M.,24-Aug-03 6:33 
GeneralHey I have a question about the edit control Pin
Snyp23-Aug-03 12:38
Snyp23-Aug-03 12:38 
GeneralRe: Hey I have a question about the edit control Pin
DougW4823-Aug-03 19:09
DougW4823-Aug-03 19:09 
GeneralRe: Hey I have a question about the edit control Pin
Snyp24-Aug-03 8:02
Snyp24-Aug-03 8:02 
Generalumm stupid question i guess Pin
Kuniva23-Aug-03 12:19
Kuniva23-Aug-03 12:19 
GeneralRe: umm stupid question i guess Pin
ZoogieZork23-Aug-03 12:53
ZoogieZork23-Aug-03 12:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.