|
GetModuleFileName(0,....);
includeh10
|
|
|
|
|
|
CString CYourDlg::GetLaunchedDir()
{
TCHAR szFullPath[MAX_PATH];
TCHAR szDir[_MAX_DIR];
TCHAR szDrive[_MAX_DRIVE];
CString strLaunched;
::GetModuleFileName(NULL, szFullPath, MAX_PATH);
_splitpath(szFullPath, szDrive, szDir, NULL, NULL);
strLaunched.Format(_T("%s%s"), szDrive, szDir);
return strLaunched;
}
Works in both MFC environment as without (of course u'd have to change the CString to some other string container).
Kuniva
--------------------------------------------
|
|
|
|
|
this is to rephrase my last question
this project must be done on c++ or vc++, it must be something like argoUML, obviosly not as advanced. i want a user to create a design from a set of icons on a pallet, and then save the design and retrieve it and edit it.... any ideas and starting points... (thanx John m. for the reply)
smile...its your destiny
|
|
|
|
|
lxxrya001 wrote:
c++ or vc++
Niether of these have builtin drawing functions or the concept of a canvas. In windows their are many choices on what graphics library to use. Win32 API, MFC, WTL and third party toolkits such as VCF or wxWindows.
John
|
|
|
|
|
Hi Friends,
I want to create a Splitter Window using Win32 API in SDK.
If any one knows how to do it, Please help me.
Thanks
|
|
|
|
|
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;
}
|
|
|
|
|
I have a problem with named mutex.
In my 1st process I am creating mutex
<br />
CreateMutex(NULL,TRUE,"Process_Running"); <br />
if(GetLastError() == ERROR_ALREADY_EXISTS) { <br />
AfxMessageBox(IDS_ALREADYRUN);<br />
}<br />
Then, in 2nd process I am try to determine, whether 1st process is running:
<br />
HANDLE hMutex = OpenMutex(0,FALSE,"Process_Running");<br />
<br />
if (hMutex != NULL)<br />
{<br />
CloseHandle(hMutex);<br />
}<br />
But in this code hMutex is always NULL ! Even if 1st process is running!
What am I doing wrong ?
|
|
|
|
|
|
|
It works!
Thank you for help !

|
|
|
|
|
how do i code for my diaolog to pop up on when user click on menu in SDI?
|
|
|
|
|
Normally I'd just read resources until I find the answer, but I'm being pretty lazy tonight and am hoping somebody will just tell me. I have an SDI application with CFormView views. Anybody who's created an application like this will know that the first thing visual studios does when you choose this selection is tell you that the printing stuff won't be done for you. That's fine, I put in the functions for printing. My question is that I want to be able to print, and use the print preview with my app. What I'm printing looks nothing like what is on the screen...and I didn't overload the OnDraw function because when I try, it puts stuff I don't want on my view, and doesn't bother showing up when I print preview. So then I tried the OnPrepareDC function...same thing with the view, but the texts I want to print actually show up behind the blank page we are all accustomed to seeing when we do a print preview. Here are my questions:
In which function should I be creating my lines of text, pictures, etc. so that they will print, but not show up on my screen?
Why is my texts, pictures, etc. not showing up in my print preview...(answering the question above may actually solve this problem, so if you know ahead of time that it will, disregard! )
Thanks a bunch for taking the time to read and respond to my excessively long post! ;P
Douglas A. Wright
dawrigh3@kent.edu
|
|
|
|
|
DougwW48 wrote:
In which function should I be creating my lines of text, pictures, etc. so that they will print, but not show up on my screen?
OnPrint()
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi
When i insert component like the MicrosoftBrowser, the studio automatically creates a wrapper class for the control, and in this wrapper class there is a function call:
CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID)
does anyone know what this does? Since i would like to implement this in pure win32api without any intervention from Microsoft Visual studio or wizard! Any constructive suggestion are highly appreciated.
Regard,
|
|
|
|
|
I want to add some text and then get a new line and write some more text.
how would I achieve this goal... anyone????
<marquee>Universal Project
|
|
|
|
|
For every new line add to your text "\r\n". Also make sure the multiline property is set.
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
http://codeproject.com/internet/zsmtp.asp[^]
I'm using this smtp class, and The to and from addresses are ok on the way out on the socket, but when they are received by the smtp server the domain name has been regex'd on by the pop server.
This happens with any smtp server I use.
bill@site.com becomes bill@site.com.domain.com whether that address is a from address or a to address
this happens with every single email in the header regardless of where it is?
I know this isn't a purely C++ question, but I was wondering if anybody knew how to keep it from doing that.
|
|
|
|
|
post this question to the article's forum!
Don't try it, just do it! 
|
|
|
|
|
I want to get some user input from some edit box variables. I have added another output pane with an edit control, I want to add some of my text and the users input... like ...
"something"+userinput
HELP, I WOULD VERY MUCH APPRECIATE IT!!!
P.S. I thought I knew this but apparently I have been developing websites so this is what happens I guess.
<marquee>Universal Project
|
|
|
|
|
Give this a try, I think it might do what you described. Good luck!
CString myOutput, userInput;
/* assuming your edit box is called EditBox */
EditBox.GetWindowText( editInput );
myOutput.Format( "something " + userInput );
/* assuming your output edit box is OutputBox */
OutputBox.SetWindowText( myOutput );
Good luck!
Douglas A. Wright
dawrigh3@kent.edu
|
|
|
|
|
Thankyou but I already have a solution. it was adding \r\n instead of just \n.
<marquee>Universal Project
|
|
|
|
|
Are there memory leaks that keep on existing once the process they originated from is terminated? :S It's just that, when i look at the pagefile usage when pressing CTRL-ALT-DEL it tends to act weird.. like, when i have a big game running its normal that it takes up a lot of memory, but sometimes when i just have little apps running (like msn and IE) it shows even more memory in use.. i don't know much about this but i think its bizarre. And in the root of my C drive is a file called pagefile.sys which is almost 400MB! is that normal? cause i dont remember seeing it there before..
Kuniva
--------------------------------------------
|
|
|
|
|
Kuniva wrote:
Are there memory leaks that keep on existing once the process they originated from is terminated?
Generally, no. The operating system knows what blocks were allocated by what process, so when the process is terminated, the blocks are deallocated. Of course, if the process triggers an allocation by another process, a device driver, etc., then that allocation may linger since it isn't owned by the process that was terminated.
Keep in mind when monitoring memory usage that the operating system is free to use unused memory for caching purposes, and IE can hardly be considered a "little app" since it keeps an in-memory cache to speed things along.
Kuniva wrote:
And in the root of my C drive is a file called pagefile.sys which is almost 400MB! is that normal?
Yes, this is completely normal. Well, normally pagefile.sys is hidden, but don't worry about it. Windows uses this file for virtual memory when physical memory runs low, and can grow or shrink it at will based on your virtual memory settings.
- Mike
|
|
|
|
|
Hi
I was wondering.. how could I get the sent messages (like the windows message WM_SETFOCUS, but for a game)
Say I click some random person in my game, how could I get the message that has just been sent?
And how could I send that message to my game from my program (if it's running, as well..)
Thanks for help
|
|
|
|
|