|
This one is really good.....try it.....
http://devcentral.iftech.com/learning/tutorials/submfc.asp
|
|
|
|
|
my code goes like this:
struct myStruct
{
CString m_string;
int m_integer;
char* m_pchar;
}
void func()
{
myStruct* s;
s->m_string = "a string";
s->m_integer = 1;
s->m_pchar = "a string too";
}
apparently the pointer s is uninitialised. how can I make this code work?
|
|
|
|
|
struct myStruct
{
CString m_string;
int m_integer;
char* m_pchar;
};
void func()
{
myStruct *s;
s=malloc(sizeof(myStruct)); //this is the key line..
s->m_integer=1; //.. blah blah
remember to free(s); at the end!
You need to initialise a memory space for the 'struct'. Another way to do this would be to NOT declare it as a pointer.
Hope this helps. I also hop i havent made any silly mistakes.. I am away froma compiler!
|
|
|
|
|
Unless you are using C, please do not use malloc - use new/delete instead. Among other things, it means you get a destructor which is called on delete. This, in turn, means your class can clean up after itself. Replace malloc with
myStruct* s = new myStruct;
at the end
delete s;
Christian
I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in.
The early bird may get the worm, but it's the second mouse that gets the cheese.
|
|
|
|
|
Oops, yes... sorry about that.
Saw a 'struct', assumed C...
My Fault.;)
|
|
|
|
|
Hi,
We use several custom file formats for storing video data in various formats. I want to write a source filter that will allow me to read in the file and output yuv (for example). I have no problem reading in the data or changing the format. I do however need some help on how to write a source filter. Can anyone give me some pointers
Cheers,
Nick
|
|
|
|
|
I writing an app which should bring itself to top upon a particular internal event. I managed to make it the toplevelwindow, but I found no way to make it have the input focus, neither the button in the taskbar to get selected.
This is my final code:
if (RNEWMESS)
{
if (pMain->IsIconic())
pMain->ShowWindow(SW_RESTORE);
pMain->SetWindowPos(&CWnd::wndTop,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
pMain->SetWindowPos(&CWnd::wndTopMost,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
pMain->SendMessage(WM_ACTIVATEAPP,(WPARAM)TRUE,(LPARAM)this->m_nThreadID);
pMain->SendMessage(WM_ACTIVATE,WA_ACTIVE);
pMain->ActivateFrame();
pChild = (CPMCFrm*) pMain->GetActiveFrame();
if (pChild)
{
pChild->ActivateFrame();
pChild->SetFocus();
pChild->SetActiveWindow();
CView* pView = pChild->GetActiveView();
if (pView)
{
pView->SetActiveWindow();
pView->SetFocus();
}
}
}
Anybody has some suggestions?
|
|
|
|
|
Call CWnd::SetForegroundWindow, which is a wrapper over API SetForegroundWindow. There are several restrictions on setting the foreground window, especially on Win2000 - you can find the details in MSDN docs on SetForegroundWindow (Platform SDK: Windows User Interface).
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Thanks!
It works fine for Win95 and NT4, but on Win2000 I had no success. Although I have applications running (on Win2000) that manage to switch themselves to the foreground. I wonder how they do that...
Daniel Schmid
|
|
|
|
|
Dan I do not have an answer for you. But I have been working on the same problem for two days. SetForeground() does not always work, especially if some other app has a system modal message displayed.
If I find the answer, I will email you. And if you find the answer, would you please email me.
Phil
at
LynnPhil@Qwest.net
|
|
|
|
|
Hello,
Im sure this has been asked before but i couldnt find it in any of the recent post.
I am looking for a good online tutorial over MFC network Programing. Either with CSocket or
CAsyncSocket.
It appears this tutorial needs to be written for a dummy cuase I've gone through Several Sample Apps and MSDN and Cant get seem to get it down.
If it was a simple chat server/client like the one included in MSDN, but with the CSocket stuff explained a little it would be perfect.
If you know of a tut like that please respond.
Thanks for any help,
HAM
|
|
|
|
|
I want to bring on top a browse item dialog box when login to my app is successful while my main frame window is hide but I can't.
Thanks for your assistance.
Do Quyet Tien
|
|
|
|
|
The main window not being visible stops SetWindowPos from working ? If you've not tried that, in your dialog it's
SetWindowPos (&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOZORDER);
Christian
I've learned that you cannot make someone love you. All you can do is stalk them and hope they panic and give in.
The early bird may get the worm, but it's the second mouse that gets the cheese.
|
|
|
|
|
|
Hello, the codegurus around the world.;) (Copy Right 2001 Masaaki Onishi)
SetWindowPos didn't work in OnInitDialog to hide its own dialog.
But, MoveWindow works.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
Make the dialog box modeless.
|
|
|
|
|
Is it possible to use DateTimePicker
control in non-MFC Win32 application?
|
|
|
|
|
The DTP control is a built-in common control, as long as you have an updated comctl32.dll, so yes it's possible.
--Mike--
http://home.inreach.com/mdunn/
The Signature, back by popular demand: Buffy. Pajamas.
|
|
|
|
|
I want to change the appearance of the scroll bar in a List View
Control.
1.How can I change a scrollbar palette?
The following code doesn't work:
InitializeFlatSB(hListViewWindow);
FlatSB_SetScrollProp(hListViewWindow,WSB_PROP_PALETTE,(int)palette,false);
2. The following code also doesn't do anything:
FlatSB_SetScrollProp(hListWindow,WSB_PROP_CYVTHUMB,10,false);
3. Is it possible to make an appearance of the scroll bar in a List View
Control based on bitmaps?
|
|
|
|
|
How can I set a bitmap on List View Control's background. And I need
to make it the way that when the user scrolls the list, bimap must
stay on it's place and doesn't scroll with the list.
|
|
|
|
|
Handle the WM_ERASEBKGND message. Of course, you have to implement all bitmap painting manually, there's no magic 'SetBackgroundBitmap' call
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
I cannot modify by turn off WS_VISIBLE in PreCreateWindow, neither call ShowWindow(SW_HIDE) in OnCreate, window will hide but it still flash once before hide.
Thanks for your assistance.
Do Quyet Tien
|
|
|
|
|
Turn off WS_VISIBLE in PreCreateWindow and call ShowWindow(SW_HIDE) in your InitInstance.
|
|
|
|
|
i have a problem with file open dialog(CFileDialog),i want it allow multiselect with the following code:
CFileDialog dialog(TRUE,_T("mid"),
_T(""),FN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT,
"MIDI files(*.mid)|*.mid|All files(*.*)|*.*||", NULL);
if (dialog.DoModal() != IDOK) return;
but if i select files more than 15,an error occur;
the MFC Library Reference say that i need to initialize the m_ofn.lpstrFile and m_ofn.nMaxFile.But how to initialize them?
Thanks in advance.
julia
|
|
|
|
|
Hello, the codegurus around the world.;)
Try this.
char szFN[256];
memset (szFN, 0, sizeof(szFN));
CFileDialog dlg (TRUE);
dlg.m_ofn.lpstrFilter = "Text Files (*.txt)\0*.txt;*.lst\0All Files (*.*)\0*.*\0";
dlg.m_ofn.lpstrTitle = _T("Open Text Files");
dlg.m_ofn.lpstrFile = szFN;
dlg.m_ofn.nMaxFile = sizeof(szFN);
dlg.m_ofn.Flags = OFN_OVERWRITEPROMPT | OFN_ALLOWMULTISELECT | OFN_ENABLEHOOK;
if (dlg.DoModal() == IDOK) {
}
int CFileDialog::DoModal()
{
ASSERT_VALID(this);
ASSERT(m_ofn.Flags & OFN_ENABLEHOOK);
ASSERT(m_ofn.lpfnHook != NULL);
ASSERT(AfxIsValidAddress(m_ofn.lpstrFile, m_ofn.nMaxFile));
DWORD nOffset = lstrlen(m_ofn.lpstrFile)+1;
ASSERT(nOffset <= m_ofn.nMaxFile);
memset(m_ofn.lpstrFile+nOffset, 0, (m_ofn.nMaxFile-nOffset)*sizeof(TCHAR));
..............
}
Have a nice day!
-Masaaki Onishi-
|
|
|
|