|
|
yes i have done that:
strPrevDate = strDate.Right(4);
tvItem.mask = TVIF_TEXT;
tvItem.pszText = strPrevDate.GetBuffer(3);
tvItem.cchTextMax = 32;
tvInsert.hParent = hRoot;
tvInsert.hInsertAfter = TVI_LAST;
tvInsert.item = tvItem;
hYearItem = m_treeCtrl.InsertItem(&tvInsert);
|
|
|
|
|
Forget about that crap, and try this instead:
CTreeCtrl& tree = GetTreeCtrl();
HTREEITEM hItem = tree.GetSelectedItem();
CString strText = tree.GetItemText(hItem);
Regards,
Alvaro
When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com
|
|
|
|
|
Hi Alvaro
GetTreeCtrl() didn't work for me, i tried it out like this:
CTreeCtrl* pTreeCtrl = (CTreeCtrl*) GetDlgItem(IDC_TREEVIEW);
HTREEITEM hItem = pTreeCtrl->GetSelectedItem();
CString strText = pTreeCtrl->GetItemText(hItem);
I now get the text correctly, thanks
But now, i want to know with which kind of 'level' we are talking about: root, child or 'child of child'
Any1 any idea?
|
|
|
|
|
I have an application that is getting NULL returned from GlobalAlloc, the error code says "not enough storage avaliable" but that does not make sence.
The application has a working set of 450Mb and a virtual set of 790Mb, my machine has 1Gb of physical ram and 2.5Gb total (including virtual memory).
This error does not happen on a machine with 2Gb of ram.
The request is only for 100Mb.
Any ideas why GlobalAlloc should fail?
Could it be address space?
Are there any compiler/linker flags I can change for MSVC 6?
|
|
|
|
|
Justin Hallet wrote:
Any ideas why GlobalAlloc should fail?
try calling GetLastError .
what are you using for uFlags on the GlobalAlloc call?
-c
Image tools: ThumbNailer, Bobber, TIFFAssembler
|
|
|
|
|
I have, GetLastError, returns ERROR_NOT_ENOUGH_MEMORY, "Not enough storage is available to process this command."
Call is - GlobalAlloc ( GMEM_MOVEABLE | GMEM_ZEROINIT, aSize ), where size is about, 1048576.
|
|
|
|
|
could be you've fragmented the memory so bad that it can't find 100MB of continuous memory. (unlikely).
do you do a lot of little allocations elsewhere?
-c
Image tools: ThumbNailer, Bobber, TIFFAssembler
|
|
|
|
|
Just a few, actually, I think you may be right here, I think it is fragmentation, I will check the size, I had assumed it was 100Mb, it could be more like 700Mb in which case fragmentation will be the problem.
|
|
|
|
|
MSDN has no information these constants!!! The web didnt either. Also looked in windows.h. I was wanting to pass this into a function...myFunc(SW_HIDE) or SW_SHOW, and wanted to see what type it is...is it an int? Where can I find this info?
Appreciate your help,
ns
|
|
|
|
|
did you try "Find in Files" for SW_HIDE, in your Vc98\Include folder ?
from WinUser.h:
// begin_r_winuser
/*
* ShowWindow() Commands
*/
#define SW_HIDE 0
#define SW_SHOWNORMAL 1
#define SW_NORMAL 1
#define SW_SHOWMINIMIZED 2
#define SW_SHOWMAXIMIZED 3
#define SW_MAXIMIZE 3
#define SW_SHOWNOACTIVATE 4
#define SW_SHOW 5
#define SW_MINIMIZE 6
#define SW_SHOWMINNOACTIVE 7
#define SW_SHOWNA 8
#define SW_RESTORE 9
#define SW_SHOWDEFAULT 10
#define SW_FORCEMINIMIZE 11
#define SW_MAX 11
-c
Image tools: ThumbNailer, Bobber, TIFFAssembler
|
|
|
|
|
I must have misspelt it I can find it now. Sorry for the bother. I actually searched first in the vc98 folder, then in the whole c drive!!! I must have misspelt it both times (rather odd) but now I type it in and viola! Thanks
Appreciate your help,
ns
|
|
|
|
|
:I want to Create a Frame/view/doc structure On a ActiveX Control,but It will be Found Memory leak! And I Found that the reasons is :
CDocManager* CDocManager::pStaticDocManager;
CPtrList* CDocManager::pStaticList;
How Can I avoid Memroy leak?
the Following is My Code :
BOOL Create()
{
if( m_pFrameWnd )
{
if( IsWindow(m_pFrameWnd->m_hWnd) ) return TRUE;
}
CSingleDocTemplate * pDocTemplate;
pDocTemplate = new CSingleDocTemplate(IDR_MAPTYPE,
RUNTIME_CLASS(CMapDoc),
RUNTIME_CLASS(CMapFrame),
RUNTIME_CLASS(CMapView));
CMapDoc * pDoc = new CMapDoc;
CCreateContext Context;
Context.m_pCurrentDoc = pDoc;
Context.m_pNewDocTemplate = pDocTemplate;
Context.m_pNewViewClass = RUNTIME_CLASS(CMapView);
Context.m_pLastView = NULL;
Context.m_pCurrentFrame = NULL;
CMapFrame * pFrameWnd = new CMapFrame;
m_pDoc = pDoc;
m_pFrameWnd = pFrameWnd;
m_pDocTemplate = pDocTemplate;
CRect rcMap;
GetClientRect(&rcMap);
BOOL ret = m_pFrameWnd->Create(AfxRegisterWndClass(CS_DBLCLKS), NULL, WS_CHILD|WS_VISIBLE, rcMap,this,NULL,&Context);
m_pFrameWnd->ShowWindow(SW_SHOW);
return ret;
}
ZHANGYIFEI
|
|
|
|
|
MFC only deletes the CDocManager class if it(MFC) created it. It looks like you are creating your own doc manager and therefore need to delete on exit.
|
|
|
|
|
I have not created CDocManager ,I don't want MFC create it too!but In fact ,MFC Create it,and leak happened! the reason is two CDocManager's static
data member!
ZHANGYIFEI
|
|
|
|
|
How to hooking api calls before the window receive a message?
I have install a CBT before creating a new process and change the child process' import table for hooking some APIs when it attached to my dll, but it doesn't work before InitInstance() completed its works.
CreateRemoteThread() maybe could help me for saving my job, but Richter said that's not implemented CreateRemoteThread() under Win98...
Thanks a lot for any suggestion.
|
|
|
|
|
There are several articles about API hooking on this page. I personally use Microsoft's "Detours" library to hook API codes other apps call.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thank you very much for your information.
I am tried to search about "detours" and "api hook" in both codeproject and MSDN site, but found nothing could help me.
May I get the link or a copy of the "detours" library from you, please? I'd like to read the source for finding out how it hooks the api before receives a message and then attach to the dll.
|
|
|
|
|
Hi,
this is the official site:
http://research.microsoft.com/sn/detours/
you can download the package from there, I just tried it
There's a PDF-File and lots of tutorials inside the package to start with.
regards
Greg
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thanks a lot, I got the great "Detours" library last night and now reading tutorials.
I am not tried to link with "Detours" library, but I thing all will be well because the implement way of "Detours" is introduce by some articles but I have weakness knowledge about that...
Thanks again, you really saved me from troubles.
|
|
|
|
|
I want to Create a Frame/view/doc structure On a ActiveX Control,but It will be Found Memory leak! And I Found that the reasons is :
CDocManager* CDocManager::pStaticDocManager;
CPtrList* CDocManager::pStaticList;
How Can I avoid Memroy leak?
the Following is My Code :
BOOL Create()
{
if( m_pFrameWnd )
{
if( IsWindow(m_pFrameWnd->m_hWnd) ) return TRUE;
}
CSingleDocTemplate * pDocTemplate;
pDocTemplate = new CSingleDocTemplate(IDR_MAPTYPE,
RUNTIME_CLASS(CMapDoc),
RUNTIME_CLASS(CMapFrame),
RUNTIME_CLASS(CMapView));
CMapDoc * pDoc = new CMapDoc;
CCreateContext Context;
Context.m_pCurrentDoc = pDoc;
Context.m_pNewDocTemplate = pDocTemplate;
Context.m_pNewViewClass = RUNTIME_CLASS(CMapView);
Context.m_pLastView = NULL;
Context.m_pCurrentFrame = NULL;
CMapFrame * pFrameWnd = new CMapFrame;
m_pDoc = pDoc;
m_pFrameWnd = pFrameWnd;
m_pDocTemplate = pDocTemplate;
CRect rcMap;
GetClientRect(&rcMap);
BOOL ret = m_pFrameWnd->Create(AfxRegisterWndClass(CS_DBLCLKS), NULL, WS_CHILD|WS_VISIBLE, rcMap,this,NULL,&Context);
m_pFrameWnd->ShowWindow(SW_SHOW);
return ret;
}
ZHANGYIFEI
|
|
|
|
|
Hi,
I am building a wind synth that uses the API midi functions of
a soundcard. m_Note2 is an int value according to the keys pressed
and m_PBAD_2 is an int value ranging from 0-127 according to the airflow
thru the synth, updated according to the timer set at 250 millisec.
When I blow into the synth a note is played every 25msec but does not
stop, because the m_note in stopnote() outdated.
I have no idea what to add to the playnote() function. Any suggestions appreciated,
my knowledge of VC++ is very limited.
Cheers,
Rob
robert.harrington2@mail.dcu.ie
void CAD_mouthDlg::PlayNote()
{
UpdateData(TRUE);
MidiOutMessage (hMidiOut, 0x00, 0x90, m_Note2,m_PBAD_2) ;
}
void CAD_mouthDlg::StopNote()
{
if(m_Key_Press == FALSE)
{
MidiOutMessage (hMidiOut, 0x00, 0x90, m_Note2,0) ;
}
else
{
}
}
void CAD_mouthDlg::OnTimer(UINT nIDEvent)
{
CAD_mouthDlg::read_analog();
CAD_mouthDlg::SetPortChigh();
CAD_mouthDlg::OnButtonReadPort();
CAD_mouthDlg::PlayNote();
CAD_mouthDlg::StopNote();
CDialog::OnTimer(nIDEvent);
}
|
|
|
|
|
bob_000 wrote:
void CAD_mouthDlg::StopNote()
{
if(m_Key_Press == FALSE)
{
MidiOutMessage (hMidiOut, 0x00, 0x90, m_Note2,0) ;
}
else
{
}
}
Well, one of your problems is that the MIDI note off message code is 0x80 (to 0x8F for different channels), not 0x90 (0x90 - 0x9F are note-on messages for channels 0-15)). As you probably know, MIDI uses a Note On message to start a note and a Note Off message to stop it.
[Edit] Oops - I just checked a MIDI spec, and a Note On message with velocity zero, which is what you're doing, should also work as a Note Off. Sorry![/Edit]
However, you're still going to run into problems. Calling StopNote() immediately after PlayNote() (assuming m_Key_Press == FALSE) will result in a note too short for you to hear. But if m_Key_Press is TRUE (so the stop message doesn't get sent), the next time your timer triggers another note on will be sent (maybe with the same pitch) without you having sent a stop message. You might get the same note played again, which will sound wierd, or the previous note might stop - it kinda depends on the synth you're sending the MIDI messages to. Anyway, wind instruments are normally monophonic so you'd want to stop the previous note before starting the new one. But that's more an app-logic problem, and that all depends on what you're trying to do!
"We are the knights who say Ni" (The Knights Who Say Ni)
|
|
|
|
|
I´m trying to get the Image attributes (width,height and dpi)
from cgm and eps files. I use the GDI+ to get it from jpg,tif
and wmf like this:
Image image(L"D:\\Code\\testbilder\\jpg1.jpg");
UINT imageHeight = image.GetHeight();
UINT imageWidth = image.GetWidth();
REAL horizResDpi = image.GetHorizontalResolution();
REAL vertiResDpi = image.GetVerticalResolution();
But I cant open eps or cgm images.
Can anybody please help me?
Vandaley
|
|
|
|
|
|