|
kilowatt wrote:
This is how VB implements their version of this.
I didnt know that. How is it done from VB?
Forget about it! Even if this is the "offical" way to do it, it has some bad limitations, especially in NTs multiuser/multidesktop environment. I strongly recommend to read the excellent article from Joseph which shows everything about this topic. Some ready to use C-Code can that takes account of this problems can be found here.
--
Daniel Lohmann
http://www.losoft.de
|
|
|
|
|
I think Nish was simply asking how you get access to the previous instance feature in VB. I don't think that just because VB implements it this way, that says this is the "official" way to do it.
|
|
|
|
|
You reference the app object and test the hPrevInstance variable. It will return true if there is an previous instance of the app, false if there is not.
If (App.PrevInstance) Then
MsgBox "Previous Instance Found"
Else
MsgBox "No Previous Instance"
End If
Basically this feature is implemented internally with the named mutex as I mentioned earlier in the thread.
|
|
|
|
|
This is what I use.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
create a static instance for a type
ex: static CMyClass *pInstance;
// you need to initialize it...
CMyClass *CMyClass::pinstance = NULL;
add the following functions
// constructing the object
CMyClass *CMyClass::GetInstance()
{
if(pInstance== NULL)
pInstance = new CMyClass;
return pInstance;
}
// destructing the object
void CSystemManager::DeleteInstance()
{
if( pInstance)
delete pInstance;
pInstance = NULL;
}
apart from constructor and destructor...
Now... you can happily access the singleton thro GetInstance() function.
call DeleteInstance() when you are done with that.
-anu
|
|
|
|
|
ihave a probelm, i got a property sheet and some property pages, when i try to add controls like buttons or whatever, the program crashes, could it be that i'm using the property page in a dockable toolbar ? there are no memory leaks anyway, i don't know how to solve it.![Cry | :((](https://codeproject.freetls.fastly.net/script/Forums/Images/smiley_cry.gif)
|
|
|
|
|
|
maybe the idea is stupid
class CBookFormatsDlg : public CDialog
{
// Construction
public:
CBookFormatsDlg(CWordFormat *pWordFormat = NULL,UINT nDlgIDD = IDD_BOOK_FORMATS,CWnd* pParent = NULL); // standard constructor
virtual ~CBookFormatsDlg();
// Dialog Data
//{{AFX_DATA(CBookFormatsDlg)
enum { IDD = IDD_BOOK_FORMATS };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
CPropertySheet* m_dlgPropSheet;
CTitleSet* m_pTitleSet;
CPageSet* m_pPageSet;
COtherSet* m_pOtherSet;
// ....
};
--------------------------------------------------------------------------------------------------
CBookFormatsDlg::CBookFormatsDlg(CWordFormat *pWordFormat,UINT nDlgIDD,CWnd* pParent /*=NULL*/)
: CDialog(nDlgIDD, pParent)
{
//{{AFX_DATA_INIT(CBookFormatsDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_dlgPropSheet = new CPropertySheet();
m_pTitleSet = new CTitleSet();
m_pPageSet = new CPageSet();
m_pOtherSet = new COtherSet();
m_pWFormat = pWordFormat;
m_pWordFormats = &(((CTdbookApp *)AfxGetApp())->m_sysWordFormats);
m_nPreSelIndex = -1;
m_nSelFormatID = -1;
}
CBookFormatsDlg::~CBookFormatsDlg()
{
if( m_pTitleSet != NULL)
delete m_pTitleSet;
if( m_pPageSet != NULL)
delete m_pPageSet;
if( m_pOtherSet != NULL)
delete m_pOtherSet;
if( m_dlgPropSheet != NULL)
delete m_dlgPropSheet;
}
BOOL CBookFormatsDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// ...
m_dlgPropSheet->AddPage(m_pTitleSet);
m_dlgPropSheet->AddPage(m_pPageSet);
m_dlgPropSheet->AddPage(m_pOtherSet);
m_dlgPropSheet->Create(this, WS_CHILD | WS_VISIBLE, 0);
m_dlgPropSheet->ModifyStyle(0, WS_TABSTOP);
m_dlgPropSheet->ModifyStyleEx(0, WS_EX_CONTROLPARENT);
CRect rcSheet;
CWnd *pWnd = GetDlgItem(IDC_SHEETS);
if( pWnd != NULL )
{
pWnd->GetWindowRect(&rcSheet);
ScreenToClient(rcSheet);
}
else
GetWindowRect(&rcSheet);
m_dlgPropSheet->SetWindowPos(NULL, rcSheet.left-4, rcSheet.top-4, rcSheet.Width(), rcSheet.Height(),
SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
m_dlgPropSheet->SetActivePage(0);
// ....
return TRUE;
}
|
|
|
|
|
I am trying to make a keyinput dialog which can then send input to any Cwnd. I had seen a keyboard project on Cp but there was one problem that it could not enter things into a child of a child because it was within the dialog.
Thus I am exploring the Attachthreadinput myself. What I don't understand is if this dialog has the CWnd of the edit or ... in another running program through maybe WM_COPYDATA, do I really need the Attachthreadinput call? What if I just send WM_COPYDATA back and forth with the keys pressed? Would this be good?
If I want to use the attachthreadinput, where would I really put this? I want to be able to get to the nested CWnd inside a dialog or View.
Thanks.
|
|
|
|
|
When I use
ATD(number)
to connect another modem (use in HyperTerminal).
I can not send command to modem because it send command as data to another modem.
And how can I use AT command to switch modem to voice mode? Can I use 2 modem to talk together?
lenhan
|
|
|
|
|
How can I get an event when modem connect to internet?
I want to write a application that execute immediately after connect to Intenet.
lenhan
|
|
|
|
|
You have to use some socket programming.There are lots of articles in CP about it and you can find out how to connect to internet and some other things.
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
'h' is always NULL!
Why!!
int main()
{
struct hostent *h;
char szName[255];
DWORD ulLen;
GetComputerName(szName,&ulLen);
h = gethostbyname(szName);
if(h == NULL)
exit(1);
printf("Host name : %s\n", h->h_name);
printf("IP Address : %s\n",inet_ntoa(*((struct in_addr *)h->h_addr)));
return 0;
}
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
Try initializing Winsock first.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
Try initializing Winsock first.
Nish
Oh, I don't know why she's
leaving, or where she's gonna go
I guess she's got her reasons but I just don't wanna know
'Cos for 24 years I've been living next door to Alice
24 years just waitin' for a chance
To tell her how I feel and maybe get a second glance
Now I gotta get used to not living next door to Alice
|
|
|
|
|
show me....
------------------------------------
Rickard Andersson, Suza Computing
ICQ#: 50302279
I'm from the winter country SWEDEN!
------------------------------------
|
|
|
|
|
Look at WSAStartup() in MSDN.
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
|
Hey all
i've taken the CDialogBar class provided by MFC and changed it in hopes of removing the dialog resource dependance and using just the CControlBar's CWnd.
Here is my code so far:
stripped down version of CDialogBar::Create()
ASSERT(pParentWnd != NULL);
ASSERT(lpszTemplateName != NULL);
m_dwStyle = (nStyle & CBRS_ALL);
CreateDlg(lpszTemplateName, pParentWnd);
CRect rect;
GetWindowRect(&rect);
m_sizeDefault = rect.Size();
SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOZORDER|SWP_NOACTIVATE|SWP_SHOWWINDOW);
I would like to scrap the Template dialog resource and just use the CControlBar, any ideas how I would do this...?
When I removed the call to CreateDlg with CreateWindow etc...SetWindowPos is asserting with a NULL pWindow?
How does this work for dialog though...?
I tried CWnd::Create() and ::CreateWindow, but didn't have much success, if any at all.
Perhaps someone could gimme some pointers cuz i'm really lost here and it's starting to frustrate me.
Thanx in advance.
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
How can I invoke-make the button be pressed, this Mode to Design-mode.
Let's say I Right click the mouse ,and want this action to take place.
Thanks Erez
|
|
|
|
|
I've been trying this for hours but I can't seem to get one main window to create and show another separate window at run time. ShowWindow() returns no error yet the new window still does not show. I'm very confused.
Would someone be so kind as to write up a small snippet of code in which one open window creates an opens a second detached window so I can see what exactly it is I'm missing.
I'm doing this in C only and using the base Win32 SDK and not MFC (which I won't even attempt until I understand how to effectively use the base Win32 SDK first).
I can understand if someone doesn't want to write up a litte piece of code but if all else fails can some one direct me towards a document or website that can? All the documentation I have thus far explain how to use single windows and unique dialogs but not multiple windows.
As well is there some macro I could use to print out debug statments (like what return values are without printing out a MessageBox() for everything? I apologize for my ignorance and stupidity and thank you all in advance.
Sean Cody (NullStream)
"Today is what ever I want it to mean."
- Beth Orton
|
|
|
|
|
For the CreateWindow problem, it would help to see your code.
For the trace, try OutputDebugString.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
I can send code upon request as the code to generate and show the 2 windows is larger than it is appropriate to post to this forum.
Sean Cody (NullStream)
"Today is what ever I want it to mean."
- Beth Orton
|
|
|
|
|
You might have a look at using SetWindowPos to see if that can make a difference - though you might have tried that already.
What OS are you using? I have noticed different behavior in this area re w9x and NT/w2k.
|
|
|
|
|
Windows XP and Visual Studio 6 SP5.
Ok. I think my problem is coming due to a misunderstanding of how things are supposed to work.
For any Win32 program you create a main window.
You have to programmatically add any controls you want to this window.
I was/is trying to create the main window yet fill it's contents with a dialog I made in the resource editor. Is this even possible?
Then I would create another window in the same fashion and it doesn't show.... ugh.
one day i'll see it.... but i don't think it will be today.
Sean Cody (NullStream)
"Today is what ever I want it to mean."
- Beth Orton
|
|
|
|