|
Christian - do you know if this would work with a Tabbed Dialog Box such as the one Derek Lakin presents 'CTabCtrlSSL' ?
I need to do something like this, but only add a new dialog one at a time, depending on if the user presses 'continue' or 'ok' .. the problem is, the next dialog depends on a control in the previous one ..
My first choice would be to create a global variable for each piece of data that needs to be passed from dialog to dialog (usually, there is only one control with the relevant data) - then when, for example 'ok' is pressed, it copies the required data from the control to the global variable. When the next dialog is initialised, it simply reads the global variable..
.. but maybe this isnt necessary/too long winded
any ideas you and others have would be appreciated.
thanks, and ho ho !!
|
|
|
|
|
Do you mean a dialog box that contains other dialog boxes, tabbed ? I'm not familiar with the article, but any dialog you create should work using this method, however if the dialogs you refer to are all children of another dialog physically ( i.e. contained as children of another dialog ), then I'd look to the class that impliments that as to how you should deal with it.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Thanks Christian ..
Im just re-reading the article now, and having a poke at the code, to try and determine exactely what's going on under the skin ...
The Article Header says "An extended tab control that allows tab pages to be added from dialog resources" .. Basically, you start with a 'parent' dialog, and then any other 'Tab' you add seems to be a 'child' dialog, but I'll
have to verify that in the actual code I guess
thanks for your help
G
|
|
|
|
|
No worries. Does mbf.com.au mean you work for the health fund my wife has joined ? Do you get a sweet flat screen, or is that just the people at the front desk ?
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
I wish to set a textbox item in my dialog box, but the
value I want to set it to is an int, where as it appears
SetDlgItemText() will only set a textbox to a CString.
This makes sense, as it is a TEXTbox, however, it is
rather inconvienient in my situation. Is it possible to
convert/change an int to a CString?
Thanks for any help!
Josh Gladieux
f16sdabest@home.com
|
|
|
|
|
This question MUST be in the FAQ and has been discussed very recently.
CString has a method called Format which works like sprintf.
CString s;
s.Format("%d", 502);
creates a string with the value "502".
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Christian Graus wrote:
This question MUST be in the FAQ and has been discussed very recently.
I just updated the FAQ to cover the conversion both ways, both to and from a string.
--Mike--
http://home.inreach.com/mdunn/
"Not our fault we are intellectually superior to the rest of the office." -- Paul Watson in the Lounge, 12/12/2001
Sonork - 100.10414 AcidHelm
|
|
|
|
|
You need to convert your int in CString.
For that you have The CString::Format function
CString strNumber;
strNumber.Format("%d", nYourNumber);
SetDlgItemText(ID_TEXT, strNumber);
Best Regards...
Chau!!! Nice Weekend...
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
Use SetDlgItemInt() instead.
--Mike--
http://home.inreach.com/mdunn/
"Not our fault we are intellectually superior to the rest of the office." -- Paul Watson in the Lounge, 12/12/2001
Sonork - 100.10414 AcidHelm
|
|
|
|
|
I'm in a middle of writing my little own framework. I've created a class; lets call it MyFrameWorkApp, and all applications must have one and only one instance of this class (or more likely a class derived from this class). This class should, like in MFC, be instanciated somewhere at global level. (i.e. Before WinMain is called) Then I want WinMain to somehow get a pointer to this instance. This is how MFC does it...
int AFXAPI AfxWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
ASSERT(hPrevInstance == NULL);
int nReturnCode = -1;
CWinThread* pThread = AfxGetThread();
CWinApp* pApp = AfxGetApp();
.
.
. Now, in my case both pThread and pApp points to the CWinApp instance, but that's normal I guess. Later in AfxWinMain, pThread->InitInstance() is called. I want the WinMain-function in my framework to do the same: Get a pointer to the MyFrameWorkApp instance, and call a particilar function. I've tried _lots_ of times to singelstep how MFC does this, my I can't figure it out. Can someone help me?
Sprudling
|
|
|
|
|
Use a Singleton Class,
That will ensure that u can always
get the singleton object thru a well
known pointer or fn and that it is created
only once.
regards,
Prem
|
|
|
|
|
Well, trying to copy MFC is fraught with danger and intrigue.
MFC tends to do a lot of monkey business behind the scenes. For instance, quite often, instead of calling new, MFC will allocate memory for an object, then call the objects constructor manually. I guess it makes sense if you consider that MFC came from DOS originally, over 10 years ago.
Anyways, how MFC does this is hidden in the constructor for CWinApp. In there, They do a few things, such as a module state variable = this (this being the CWinApp object) and doing some asserts that will assert if you try to create more than one instance.
This isn't the best way to do this, however. The better way would be to make your MyFrameWorkApp a singleton object, which makes it impossible to create more than one instance. If you don't know what a singleton is, I suggest doing some web searches on it, or buying the most excellent book "Design Patterns".
The reason you can't single-step into this is that the CWinApp's constructor get's called *BEFORE* WinMain. You have to put a breakpoint in CWinApp's constructor before you execute the app.
--
Where are we going? And why am I in this handbasket?
|
|
|
|
|
HI!
Is it possible to do this:
// Timer one
SetTimer(1, 1000, NULL);
// Timer two
SetTimer(2, 1000. NULL);
My app is kind of an alarm app. It checks the alarm time if it is equal with the current time.. it works just fine! But when the second timer is running too, witch is set to interval 1000 too, the first timer wont be killed when the time is equal to alarm time!! WHY?? I guess it's because it will not work with two timers with the same interval, but I've tride to set the second to 1001 milisec but it wont work any better!"! ( (
I may be didn't explained so good but you can at least answer this:
Is it possible to do this:
// Timer one
SetTimer(1, 1000, NULL);
// Timer two
SetTimer(2, 1000. NULL);
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
Rickard Andersson wrote:
Is it possible to do this:
// Timer one
SetTimer(1, 1000, NULL);
// Timer two
SetTimer(2, 1000. NULL);
Yes, of course. You should post some more code to show how you're setting them up and using them.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
Ok, here is the OnTimer function:
All comments are writen in SWEDISH...
The problem was that when I try to launch open the dialog in timer 1 the KillTimer func doesn't seems to be called or something? The dialog boxs appears, and appears, and appears.... but when next minut comes then it can be called and timer 1 is killed... Hope I could explain it! And this happens when I have to timers in use at the same time
the reg vaiables are CHKLM objects, the registry class here from code project... is there anything else you want? PLEASE TELL ME!! IF YOU CAN TELL ME HOW TO AVOID THIS YOU'RE BEST!
void CReminderSEDlg::OnTimer(UINT nIDEvent)
{
reg.SetRegistryKey(_T("CodeCracker"));
switch(nIDEvent)
{
case 2:
{
// Hämta aktuell tid
CTime CurTime;
CurTime = CTime::GetCurrentTime();
// Spara den aktuella tiden i ett CString objekt
CString szCurTime;
szCurTime.Format("%d:%d", CurTime.GetHour(), CurTime.GetMinute());
//AfxMessageBox(szCurTime);
if( m_szKomIhagTid == szCurTime )
{
int ret = KillTimer(2);
CString str;
str.Format("%d",ret);
AfxMessageBox(str);
sndPlaySound("STANDARD2.WAV", SND_ASYNC);
CAlertDlg dlg;
dlg.DoModal();
reg.WriteProfileInt(_T("CMeddelandeDlg"), _T("Aktivate"), 0);
m_sPamin.SetBitmap(::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP1)));
m_KiTid = "";
Invalidate();
UpdateData(FALSE);
}
}
case 1:
{
// Hämta aktuell tid
CTime CurTime;
CurTime = CTime::GetCurrentTime();
// Spara den aktuella tiden i ett CString objekt
CString szCurTime;
szCurTime.Format("%d:%d", CurTime.GetHour(), CurTime.GetMinute());
// Hämta alarm tiden från registret
int nHour = reg.GetProfileInt(_T("CConfigDlg"), _T("Hours"), NULL);
int nMinute = reg.GetProfileInt(_T("CConfigDlg"), _T("Minutes"), NULL);
// Spara alarm tiden i ett CString objekt
CString szAlarmTime;
szAlarmTime.Format("%s:%s", Minutes(nHour), Minutes(nMinute));
if( szAlarmTime == szCurTime )
{
// Döda timer nu så vi inte får problem
KillTimer(1);
reg.WriteProfileInt(_T("CConfigDlg"), _T("Aktivate"), 0);
m_MorgonAlarm.SetBitmap(::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP1)));
GetDlgItem(IDC_BUTTON3)->EnableWindow(TRUE);
m_VackTid = "";
Invalidate();
UpdateData(FALSE);
// Kolla om användaren harvalt en MP3 eller en WAV som alarm ljud
int Mp3OrWav = reg.GetProfileInt(_T("CLjudDlg"), _T("Mp3OrWav"), NULL);
if( Mp3OrWav == 1 ) // Det är en mp3
{
// Spela ljudet
PlayMp3(FALSE);
//AfxMessageBox("Mp3");
// Skapa fönstret som välkomnar di på morgonen
CWakeUpDlg dlg;
int i = dlg.DoModal(); // Visa det
if( i == IDOK ) // Fånga upp vad användaren tryckte på
{
//MCIWndStop(m_WndPlay);
PlayMp3(TRUE);
}
else if( i == IDCANCEL )
{
reg.SetRegistryKey(_T("CodeCracker"));
CString str;
str = reg.GetProfileString(_T("Main"), _T("MailPath"), NULL);
if( str.IsEmpty() == TRUE )
{
PlayMp3(TRUE);
CSystemTray::MaximiseFromTray(this);
}
else
{
PlayMp3(TRUE);
WinExec(str,SW_SHOW);
}
}
}
else
{
// Skapa fönstret som välkomnar dig på morgonen
CWakeUpDlg dlg;
// Spela ljudet
PlayWav(FALSE);
int i = dlg.DoModal();
if( i == IDOK )
{
PlayWav(TRUE);
CSystemTray::MaximiseFromTray(this);
}
else if( i == IDCANCEL )
{
reg.SetRegistryKey(_T("CodeCracker"));
CString str;
str = reg.GetProfileString(_T("Main"), _T("MailPath"), NULL);
if( str.IsEmpty() == TRUE )
{
PlayWav(TRUE);
CSystemTray::MaximiseFromTray(this);
}
else
{
PlayWav(TRUE);
WinExec(str, SW_SHOW);
}
}
}
}
}break;
default:
break;
}
CBitmapDialog::OnTimer(nIDEvent);
}
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
You need to put a break between your switch statements - as it stands, case 2 causes both blocks of code to execute.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
DAMN MOI!!!
You did it again you... Argh!!
I want your experience in my brain!!
A BIG F.U.C.K.I.N.G THANK YOU!!
!!!!!
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
I have a class derived from CWinThread. I create an instance of the object using new and then call CreateThread. So now I have a thread running. My question is:
What are the consequences, if any, if I call a member function of that object? Say I set the thread running then called the objects getCount() function. I've not had any luck with this. Just wondering if it's impossible or is there some stack issues I'm not aware of.
Seems like a strange question I hope I explained well enough. Lemme know if I didn't.
|
|
|
|
|
nay wrote:
I've not had any luck with this.
What do you mean?
nay wrote:
. Just wondering if it's impossible or is there some stack issues I'm not aware of.
You're asking if you can call member functions of the object you created using new, right? It should be OK; you'll just be calling the functions from within the original thread instead of the one just created.
Regards,
Alvaro
|
|
|
|
|
"I've not had any luck with this."
What I meant was I did call the function after I set the thread running. I was passing a pointer into the function. But as soon as I step into the function (in the debugger) the pointer is garbage. I thought it could be because the function is in the same object as a thread.
Alvaro Mendez wrote:
It should be OK; you'll just be calling the functions from within the original thread instead of the one just created.
Yeah that's what I thought but I wanted an un biased opinion. Thanks for the reply!
nay
|
|
|
|
|
I have a function that is called be visual basic to draw to a picturebox. What that picturebox has is some video on it and I want to be able to change the colours of the image. I am trying to use CreateDIBSection but I seem to be missing something as I can't change the colors. I know that I have the right DC because I can draw a rectangle on it but I can't seem to get a proper bit set. Here is my code:
void __stdcall OverlayMask(long hWnd, long MaskArray)
{
RECT rc;
LONG lWidth = 0;
LONG lHeight = 0;
BITMAPINFO bmi;
HBITMAP hbmp = NULL;
BYTE* bpDIBits = NULL;
GetClientRect((HWND)hWnd, &rc);
lWidth = rc.right - rc.left;
lHeight = rc.bottom - rc.top;
ZeroMemory(&bmi, sizeof(BITMAPINFO));
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = lWidth;
bmi.bmiHeader.biHeight = lHeight;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = 24;
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biXPelsPerMeter = 72;
bmi.bmiHeader.biYPelsPerMeter = 72;
HDC tmpDC = GetDC((HWND)hWnd);
hbmp = CreateDIBSection(
tmpDC, (LPBITMAPINFO)&bmi, DIB_RGB_COLORS,
(LPVOID*)&bpDIBits,
NULL, 0);
if (hbmp == NULL) AtlTrace("Unable to create DIB Section\n");
if (bpDIBits == NULL) AtlTrace("Unable to create DIBits\n");
HBRUSH hBrush = CreateSolidBrush(RGB(0xFF, 0x0F, 0xF0));
FillRect( tmpDC, &rc, hBrush ); // <- This works fine.
for (int i = 0; i < (lWidth*lHeight/3); i++) //<- This
{
*(bpDIBits++) = 0;
*(bpDIBits++);
*(bpDIBits++) = 0x66;
} // <- doesn't
AtlTrace("1) OverlayMask: %x %x", hWnd, MaskArray);
GdiFlush();
ReleaseDC((HWND)hWnd, tmpDC);
}
Thanks in advance,
Clint Singer
|
|
|
|
|
Well, after creating the DIB section (which I assume you have no problems with) and doing whatever you want with bpDIBits you will have to paint the bitmap by:- creating a DC compatible with tmpDC (use
CreateCompatibleDC for this),
- selecting the bitmap you've created into this compatible DC with
SelectObject(compatibleDC,hbmp) ,
- doing the actual painting to
tmpDC with BitBlt(tmpDC,0,0,lWidth,lHeight,compatibleDC,0,0,SRCCOPY)
Also, don't forget to clean everything up (compatibleDC ,hbmp ...)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I´m having trouble using "global" ado recordset pointers in a project.
I have a recordset in a +/- fixed window, that I want to used by other windows that are constantly beeing created and destroyed.
I can access the window pointer easily but when i try to access the recordset pointer the program crashes. The weird thing is that i can visualise the pointer in the debug windows correctly. the code is below, what am I dooing wrong?
class CMainFrame : public CFrameWnd{...
public:
_ConnectionPtr pCon;
CWnd *pTrabalhadoresView;
...}
class CDLG_TRABALHADORES_VIEW : public CResizableFormView{...
public:
_RecordsetPtr
pRstTrabalhadoresDados;
...}
void CDLG_TRABALHADORES_VIEW::OnInitialUpdate()
{...
pMain= (CMainFrame *)AfxGetMainWnd();
pRstTrabalhadoresDados.CreateInstance(__uuidof(Recordset));
pRstTrabalhadoresDados->Open("trabalhadoresdados",_variant_t((IDispatch *)pMain->pCon,true),adOpenDynamic,adLockOptimistic,adCmdTableDirect);
...}
void AnotherWindow::OnSomething(){...
CMainFrame* pMain= (CMainFrame *)AfxGetMainWnd();
CDLG_TRABALHADORES_VIEW* pTrabalhadoresView=(CDLG_TRABALHADORES_VIEW*)pMain->pTrabalhadoresView;
_RecordsetPtr pRstTrabalhadoresData=pTrabalhadoresView->pRstTrabalhadoresDados;
/* UNHANDLED EXCEPTION IN TEST.exe: 0xc0000005: Access violation */
...}
Texas
|
|
|
|
|
Texas:
You need to put the recordset, in the MainFrame and to Instance it in the MainFram. Also you can make the same in the CWinApp Class...
You will can access to the recordset from every window, using
<br />
CWinApp::_RecordsetPtr<br /> \
best Regards...
Chau!!! and good weekend!!!
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
Hi,
If I want to find unwanted DLL in the system, how should I find it, is there any method available
Kindly reply me
Regards
John
|
|
|
|
|