|
Hi
I tried to delete the one menu from the main menu bar. I did following:
CMenu MainMenu = ((CMainFrame*)AfxGetMainWnd())->GetMenu();
CMenu toolmenu = MainMenu ->GetSubMenu(1);
while( toolmenu->GetMenuItemCount() > 0 )
{
ret = toolmenu->DeleteMenu(0,MF_BYPOSITION);
}
I checked the "ret" value. it is "1".
But the "Tool" menu is still there. Why I can not delete it?
Best regards,
|
|
|
|
|
The code should not even compile.
GetMenu[^] and GetSubMenu[^] returns CMenu pointers.
So the declaration must be CMenu* MainMenu and CMenu* toolmenu .
The DeleteMenu[^] that you are calling will delete the first menu item in the second sub menu and not an entire menu unless there is a popup menu as the menu item. For example, in Visual Studio this menu item is the Undo item in the Edit submenu.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
I typed in code here. It might have some typo. It compiles.
My "DeleteMenu" return "1". From MSDN, it means "DeleteMenu" executes successfully.
But I still saw that menu over there.
Thanks,
|
|
|
|
|
hi all,
i need to get the table names from .mdb file in MFC.Can any on e help in this regard.
Thanks in advance.
|
|
|
|
|
Hi,
Did you search CodeProject or Google?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
I searched from both.but i didn't get the suitable one.So that only i posted this question.
|
|
|
|
|
suthakar56 wrote: I searched from both.but i didn't get the suitable one.So that only i posted this question.
Strange! CP search engine returned the following article as the first result while I searched for "MFC access":
Easy way to mix the MFC Document/View and MS Access database applications.[^]
I sure did get more relevant results when I modified the search terms. Take a look at the CDatabase[^] class as well for your need.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
try following, I didn't tried it my self just found on googling
SELECT [Name] from msysobjects where ([type] =1 and Flags = 0) or [type] = 6
|
|
|
|
|
Hi all
How can i convert CString to long.I am try this
CString Content="000995688787";
int newintval=atoi(Content);
result is
newintval=225212472
and
__int64 n64Tmp=_atoi64(Content);
result is
n64Tmp=225212472
|
|
|
|
|
You must have used atol (or rather _ttol ) instead of atoi . See CString::Format() member if you're already using CString .
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Hello, I am prashant workign with one company and doing the Graph Designing into my application. now the issue is that i create the function for populating the graph data but it takes to much time to populate data.
Can any body tell me how to reduce the time for populating data.
the following is my function from which i draw the graph data from one table.
void D_ScripGraphWnd::OnDraw(CDC *pDC)
{
CRect crect;
BOOL b;
CPen CenterPen, AxisPen, SlotPen, DrawPenRise, DrawPenFall;
CBrush brush;
CFont font;
CPen* OldPen;
CFont *OldFont;
int left, right, top, bottom, Height, Width ;
b = CenterPen.CreatePen(PS_DASH, 0, m_GraphColor_ula[REFERENCE_DATA]);
GetClientRect(crect);
Height = m_YSlots_l * m_SlotWidthY_l + 2*m_MarginY_l ;
Width = m_XSlots_l * m_SlotWidthX_l + 2*m_MarginX_l ;
crect.left = 0;
SetScaleToFitSize;
if(crect.right < Width)
crect.right = Width;
crect.top = 0;
if(crect.bottom < Height)
crect.bottom = Height;
pDC->FillRect(crect, &brush);
pDC->SetBkMode(TRANSPARENT);
left = m_MarginX_l ;
right = Width - m_MarginX_l;
top = m_MarginY_l ;
bottom = Height - m_MarginY_l;
OldPen = pDC->SelectObject(&SlotPen);
OldFont = pDC->SelectObject(&font);
char l_StartTime_ca[TIME_STAMP_LEN] = "";
char l_CurrTime_ca[TIME_STAMP_LEN] = "";
CTimeSpan l_TimeSpan_cl(0,0,30,0);
CTime l_SeriesStartTime_cl, l_SeriesCurrTime_cl;
CTime l_IndexStartTime_cl, l_IndexCurrTime_cl;
CTime l_StartTime_cl, l_CurrTime_cl;
l_SeriesStartTime_cl = l_SeriesCurrTime_cl = NULL;
l_IndexStartTime_cl = l_IndexCurrTime_cl = NULL;
ScripGraphInfo_T* l_ScripGraphInfo_stp;
l_TimeSpan_cl = CTimeSpan(0,1,00,0);
int l_i_l;
int minutes;
if(m_ScripGraphTable_clp->m_maxEntries_l != 0 && m_ScripGraphTable_clp->m_IndexQuerySuccess_b == TRUE )
{
//To find out the starting time on X-Axis.
l_ScripGraphInfo_stp = (ScripGraphInfo_T *)m_ScripGraphTable_clp->GetAt(0);
if(l_ScripGraphInfo_stp == NULL)
return;
if(l_ScripGraphInfo_stp->TimeStamp_uca[MM] >= 30)
minutes = 30;
if(l_ScripGraphInfo_stp->TimeStamp_uca[MM] < 30)
minutes = 0;
l_IndexStartTime_cl = CTime(l_ScripGraphInfo_stp->TimeStamp_uca[CC]*100 + l_ScripGraphInfo_stp->TimeStamp_uca[YY],
l_ScripGraphInfo_stp->TimeStamp_uca[MO],
l_ScripGraphInfo_stp->TimeStamp_uca[DD],
l_ScripGraphInfo_stp->TimeStamp_uca[HH],
minutes,
0);
l_ScripGraphInfo_stp = (ScripGraphInfo_T *)m_ScripGraphTable_clp->GetAt(m_ScripGraphTable_clp->m_maxEntries_l-1);
if(l_ScripGraphInfo_stp == NULL)
return;
l_IndexCurrTime_cl = CTime(l_ScripGraphInfo_stp->TimeStamp_uca[CC]*100 + l_ScripGraphInfo_stp->TimeStamp_uca[YY],
l_ScripGraphInfo_stp->TimeStamp_uca[MO],
l_ScripGraphInfo_stp->TimeStamp_uca[DD],
l_ScripGraphInfo_stp->TimeStamp_uca[HH],
l_ScripGraphInfo_stp->TimeStamp_uca[MM],
0);
}
strcpy(l_StartTime_ca, l_IndexStartTime_cl.Format("%H:%M"));
l_StartTime_cl = l_IndexStartTime_cl;
strcpy(l_CurrTime_ca, l_IndexCurrTime_cl.Format("%H:%M"));
l_CurrTime_cl = l_IndexCurrTime_cl;
pDC->SetTextColor(m_GraphColor_ula[AXIS_LABELS]);
for(l_i_l = 0; l_i_l <= m_XSlots_l; l_i_l++)
{
pDC->MoveTo(left, top);
pDC->LineTo(left, bottom);
if(m_DisplayXScale_b)
{
if(m_InitTime_cl != NULL && (l_i_l %2 == 0))
{
CTimeSpan l_Span_cl = l_StartTime_cl - l_CurrTime_cl;
if(l_Span_cl <= l_TimeSpan_cl)
pDC->TextOut(left-10 , bottom+5, l_StartTime_ca);
l_StartTime_cl += l_TimeSpan_cl;
strcpy(l_StartTime_ca, l_StartTime_cl.Format("%H:%M"));
}
}
left += m_SlotWidthX_l;
}
char l_buff_ca[20];
int j = m_Origin_l + m_YSlots_l*SlotWidthY;
left = m_MarginX_l;
for(l_i_l=0; l_i_l<=m_YSlots_l; l_i_l++)
{
pDC->MoveTo(left, top);
pDC->LineTo(right, top);
sprintf(l_buff_ca, "%d", j);
if(m_DisplayYScale_b)
{
if ((strcmp(g_SystemInfo_st.BrokerCode_ca, "") != 0) &&
(strcmp(g_SystemInfo_st.TraderCode_ca, "") != 0))
{
if(m_ScripGraphTable_clp->m_maxEntries_l > 0 )
pDC->TextOut(left - m_MarginX_l, top-2 , l_buff_ca);
}
}
top += SlotWidthY;
j -= SlotWidthY;
}
top = m_MarginY_l ;
pDC->SelectObject(&AxisPen);
pDC->MoveTo(left, top);
pDC->LineTo(left, bottom);
pDC->MoveTo(left, bottom);
pDC->LineTo(right, bottom);
pDC->SelectObject(&CenterPen);
if ((strcmp(g_SystemInfo_st.BrokerCode_ca, "") != 0) &&
(strcmp(g_SystemInfo_st.TraderCode_ca, "") != 0))
{
PrevCloseY = int(l_ScripDayOpen1)- m_Origin_l;
PrevCloseY = bottom-PrevCloseY;
pDC->MoveTo(left, PrevCloseY);
pDC->LineTo(right,PrevCloseY);
}
CString key;
char temp[20];
int x,y;
m_tooltip.Activate(TRUE);
for(l_i_l = 0; (l_i_l < m_ScripGraphTable_clp->m_maxEntries_l && m_InitTime_cl != NULL); l_i_l++)
// for( pos = g_IndexMap_cl.GetStartPosition(); pos != NULL; )
{
if(m_MinY_l == -1 || m_MaxY_l == -1)
return;
l_ScripGraphInfo_stp = (ScripGraphInfo_T* )m_ScripGraphTable_clp->GetAt(l_i_l);
if(l_ScripGraphInfo_stp == NULL)
return;
strcpy(l_CurrTime_ca, "");
if(l_ScripGraphInfo_stp->TimeStamp_uca[HH] < 10)
strcpy(l_CurrTime_ca, "0");
sprintf(temp, "%d",l_ScripGraphInfo_stp->TimeStamp_uca[HH]);
strcat(l_CurrTime_ca, temp);
if(l_ScripGraphInfo_stp->TimeStamp_uca[MM] < 10)
strcat(l_CurrTime_ca, "0");
sprintf(temp, "%d",l_ScripGraphInfo_stp->TimeStamp_uca[MM]);
strcat(l_CurrTime_ca, temp);
l_CurrTime_cl = CTime(l_ScripGraphInfo_stp->TimeStamp_uca[CC]*100 + l_ScripGraphInfo_stp->TimeStamp_uca[YY],
l_ScripGraphInfo_stp->TimeStamp_uca[MO],
l_ScripGraphInfo_stp->TimeStamp_uca[DD],
l_ScripGraphInfo_stp->TimeStamp_uca[HH],
l_ScripGraphInfo_stp->TimeStamp_uca[MM],
0/*l_ScripGraphInfo_stp->TimeStamp_uca[SS]*/);
CString l_inittime_cl = m_InitTime_cl.Format("%H, %M, %S");
CString l_currtime_cl = l_CurrTime_cl.Format("%H, %M, %S");
l_TimeSpan_cl = l_CurrTime_cl - m_InitTime_cl;
CString l_timespan_cl = l_TimeSpan_cl.Format("%H, %M, %S");
x = l_TimeSpan_cl.GetTotalMinutes();
if(x < 0)
{
IF_ERROR1(1, "Invalid time rcvd.");
return;
}
y= (int)l_ScripGraphInfo_stp->ScripValue_l/10000 ;/// 100;
if(y == 0)
continue;
AdjustSlots(x, y);
y -= m_Origin_l;
if(l_i_l == 0)
{
pDC->MoveTo(left+x, bottom-y);
if(l_ScripGraphInfo_stp->ScripValue_l/10000< l_ScripDayOpen1)
pDC->SetPixel(left+x, bottom-y, m_GraphColor_ula[INDEX_FALLING]);
else
pDC->SetPixel(left+x, bottom-y, m_GraphColor_ula[INDEX_RISING]);
}
CPoint l_CurrPt_cl = pDC->GetCurrentPosition();
if(l_ScripGraphInfo_stp->ScripValue_l/10000 < l_ScripDayOpen1)//Prev Close
// if((long)indexval < m_ScripGraphTable_clp->l_ScripDayOpen1)
pDC->SelectObject(&DrawPenFall);
else
pDC->SelectObject(&DrawPenRise);
switch(m_GraphStyle_s)
{
case LINESTYLE :
//Consider origin as (left,top) of the window, so graph grows down.
if(l_CurrPt_cl.y < PrevCloseY && (bottom-y) >= PrevCloseY)
{
pDC->SelectObject(&DrawPenRise);
pDC->LineTo(left+x, PrevCloseY);
pDC->SelectObject(&DrawPenFall);
pDC->LineTo(left+x, bottom-y);
}
if(l_CurrPt_cl.y > PrevCloseY && (bottom-y) <= PrevCloseY)
{
pDC->SelectObject(&DrawPenFall);
pDC->LineTo(left+x, PrevCloseY);
pDC->SelectObject(&DrawPenRise);
pDC->LineTo(left+x, bottom-y);
}
pDC->LineTo(left+x, bottom-y);
break;
case BARSTYLE :
pDC->MoveTo(x+left, PrevCloseY);
pDC->LineTo(x+left, bottom-y);
break;
default :
if(l_ScripGraphInfo_stp->ScripValue_l/10000 < l_ScripDayOpen1)
pDC->SetPixel(x+MarginX, bottom-y, m_GraphColor_ula[INDEX_FALLING]);
else
pDC->SetPixel(x+MarginX, bottom-y, m_GraphColor_ula[INDEX_RISING]); break;
}
}
pDC->SelectObject(OldFont);
pDC->SelectObject(OldPen);
CenterPen.DeleteObject();
AxisPen.DeleteObject();
SlotPen.DeleteObject();
DrawPenRise.DeleteObject();
DrawPenFall.DeleteObject();
brush.DeleteObject();
font.DeleteObject();
return;
}
Can any body tell me how to reduce time to populating data.
|
|
|
|
|
Please format your code properly because as it is now, it is very difficult to read.
Now to your question: if it is that slow, it's maybe because you are redrawing EVERYTHING each time a repaint is requested. Are you displaying a kind of dynamic chart ?
If you need a standard charting control, you can also look at my sig. I've developped one which is I think pretty ok regarding to performances.
|
|
|
|
|
Hi All,
I want to create an Add-In for MS-Outlook in MFC. Please guide me how to do that?
|
|
|
|
|
|
Hi,
im overriding Create function of Modeless Dialog...to increase the font and Dialog size along with the controls inside it... as follows...
BOOL CTestDlgDlg::Create(UINT nID, CWnd* pParent)
{
CDialogTemplate dlt;
// int nResult;
// load dialog template
if (!dlt.Load(MAKEINTRESOURCE(CTestDlgDlg::IDD))) return FALSE;
// get pointer to the modified dialog template
LPSTR pdata = (LPSTR)GlobalLock(dlt.m_hTemplate);
LPDLGTEMPLATE pDlgTemplate = (LPDLGTEMPLATE)pdata;
//pDlgTemplate->style |= DS_SETFONT;
// set your own font, for example "Arial", 10 pts.
dlt.SetFont(L"Century Schoolbook", 18);
// let MFC know that you are using your own template
m_lpszTemplateName = NULL;
//InitModalIndirect(pdata);
// display dialog box
//nResult = CDialog::DoModal();
// unlock memory object
// CDialog::Create(nID,pParent);
BOOL bret CDialog::CreateDlgIndirect(pDlgTemplate, pParent, AfxGetInstanceHandle());
GlobalUnlock(dlt.m_hTemplate);
return bret;
}
The size of the DialogBox along with the controls inside it are getting increased except
the Title bar of the DialogBox.Even the Text is also not getting increased.Pls let me know how can i increase the size of the Title bar along with the font size..without using custom titlebar...
|
|
|
|
|
The font of the title bar of a Window is a system-wide setting and cannot be altered for one particular window. You can see the current font setting for title bars in the Advanced Appearance option of the display settings in the control panel. In fact there are separate settings for the active title bar and the inactive title bar.
If you want a particular window to have a different look for its title bar, you will need to create a dialog box without a title bar, draw the title bar yourself and then return HTCAPTION from the WM_NCHITTEST message handler when the user clicks on the drawn title bar.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
I'm recording audio and I don't want to record silence. How can I do that? I'm recording using wimmm.
Is there a command or something like that?
Thank you
|
|
|
|
|
I dont know wimmm, but essentially silence are sample-values in a wave-file that aprox. 0 (there could be some noise). With that knowlegde you could create a program that modifies the wavefile... The Wavefile format is VERY easy, it's just a header followed by samplespoints...
rozis
|
|
|
|
|
hi all,
i have to set proxy while sending the xmlhttprequest to server for that after searching on google i found that i should go through setproxy() but i didnt exactly get that how i should use this method.
i am having proxy addresses as IP address, so can anyone please tell me how to use this function.
Thanks A Ton
Ash_VCPP
walking over water is just knowing where the stones are.....
|
|
|
|
|
hi all,
i have a service application, which maintains a record of each and every USB being used in the windows system.
in brief, my problem is with the hashmap values getting corrupted in between two threads. one thread picks the database path where values are to be written and other thread writes into that database path.
Service crashes at the, when the below codes are executed.
WaitForSingleObject(*hThreadIterBegin->second,INFINITE);
rename(hThreadIterBegin->first->c_str(),newFileName.c_str());
ReleaseMutex(*hThreadIterBegin->second);
The first thread fetches the values and the values are sent to the second thread so that it can write the necessary things to the fetched value which is the path of the database. but the hashmap value crashes at some point due to which the service crahses at above code executions.
i am not able to identify the exact reason, as to why the value of ThreadMutexMapPrimary changes or crashes when it is called from the second thread???
i am attaching the code below, with declarations and values i received while debugging.
Thankyou.
**************************
Variable declarations
---------------------
cahr queryFile[256];
string queryFileString;
int currentMap;
hash_map <std::string*, HANDLE*> ThreadMutexMapPrimary;
hash_map <std::string*, HANDLE*>::iterator hThreadIterBegin;
hash_map <std::string*, HANDLE*>::iterator hThreadIterEnd;
**************************
**********************************************************************************************
FUNCTION CALL
-------------
In 1st Thread:-> For fetching
string queryFileString = queryFile;
HANDLE presentMutex = CreateMutex(NULL,FALSE,NULL);
if(presentMutex == NULL)
{
WriteLog("Error Creating Mutex");
}
else
if(currentMap == 1)
ThreadMutexMapPrimary.insert(hash_map <std::string*, HANDLE*>::value_type(&queryFileString,&presentMutex));
else
ThreadMutexMapSecondary.insert(hash_map <std::string*, HANDLE*>::value_type(&queryFileString,&presentMutex));
In 2nd Thread:-> For writing values
switch(currentMap)
{
case 1:
if(ThreadMutexMapPrimary.empty())
{
WriteLog("Hash Map Empty No record to Write");
break;
}
hThreadIterBegin = ThreadMutexMapPrimary.begin();
hThreadIterEnd = ThreadMutexMapPrimary.end();
currentMap = 2;
currentMappingSetReplaced = true;
break;
case 2:
if(ThreadMutexMapSecondary.empty())
{
WriteLog("Hash Map Empty No record to Write");
break;
}
hThreadIterBegin = ThreadMutexMapSecondary.begin();
hThreadIterEnd = ThreadMutexMapSecondary.end();
currentMap = 1;
currentMappingSetReplaced = true;
break;
}
DebugLog("after swtich(currentMap)");
if(currentMappingSetReplaced == true)
{
while((hThreadIterBegin != hThreadIterEnd))
{
WriteLog("Beginning Database Archival System...\n");
string parameter;
string DatabaseName;
remove(newFileName.c_str());
WaitForSingleObject(*hThreadIterBegin->second,INFINITE); ----> service crashes here
rename(hThreadIterBegin->first->c_str(),newFileName.c_str()); ---
ReleaseMutex(*hThreadIterBegin->second);
**************************************************************************************************
Debug Values:->
----------
value of queryFile -> "C:\windows\Logs\Tsql\Jul2009.sql"
value of queryFileString ->"C:\windows\Logs\Tsql\Jul2009.sql"
value of currentMap = 1
ThreadMutexMapPrimary -> [1](("C"\Windows\Logs\Tsql\Jul2009.sql",0x0201bae)) --> value in 1st thread
ThreadMutexMapPrimary -> [1]((0x0201ff74 {_Bx={...} _Mysize=??? _Myres=??? },0x0201bae)) -> value in second thread,changes and is crashed.
newFileName.c_str() -> "C:\windows\Logs\Tsql\Jul2009.sql";-----> to be deleted and new the value of thread mutex map to be inserted.
*******************************************
|
|
|
|
|
Your problem seems to possibly be related to an issue we saw in our own software. Switching to an alternate STL provider fixed our issues. See
http://support.microsoft.com/kb/813810[^]
You may well be being affected by this. BTW we switched to STLport a free STL implementation.
If you vote me down, my score will only get lower
|
|
|
|
|
[id(0x60060001), helpcontext(0x000061aa)]
HRESULT GetComponents([in, out] SAFEARRAY(VARIANT) oAxisComponentsArray);
I want to know how to realize the COM in C++ with InvokeHelper.
Thanks
|
|
|
|
|
In the IDL file it should be [in, out] SAFEARRAY(VARIANT)* oAxisComponentsArray
In the .h and .cpp files it should be SAFEARRAY** oAxisComponentsArray
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Superman,thanks a lot.
Could you please tell me how to realize the SAFEARRAY(VARIANT) oAxisComponentsArray with C++, and how to write InvokeHelper?
|
|
|
|
|
I record audio with several microphones and I need to know the microphone that I used with each recording.
Can anyone help me? How can I identify the microphone in the recording?
Is there a command or something like that?
Thank you
|
|
|
|
|