|
Does anyone know how to insert the EventViewer MMC Snap-in into an MFC application?
Thanks in advance,
Dragos
|
|
|
|
|
In VC++ 6.0 you can find an item "user defined keywords" in the 'Tools - Options - Format' menu.
I'm just woundering if this means you can supply your own list of keywords which the IDE should recognize...
If so, I would really like to know how to define this list.
Thankz...
Don't think you are, know you are...
|
|
|
|
|
I just cut and pasted from a page in MSDN:
mk:@MSITStore:C:\Program%20Files\Microsoft%20Visual%20Studio\MSDN\2001OCT\1033\vcug.chm::/html/_asug_set_syntax_coloring.htm[^]
To set syntax coloring for user-defined keywords
In the same directory as msdev.exe, use the Text editor or Windows Notepad to create a text-only file named usertype.dat.
Add your keywords to usertype.dat, one keyword per line.
Note The usertype.dat file is read during initialization. It cannot be renamed, nor can it be reloaded during an editing session. The syntax coloring mechanism checks the usertype.dat file last. Thus, all previously defined color settings take precedence over the user-defined keywords.
Save the file as a text-only file, exit, and then restart Visual Studio.
From the Tools menu, choose Options.
Select the Format tab.
In the Colors box, select User Defined Keywords.
Set the font, font size, foreground color, and background color to your preferences.
For more information, see To change colors used in syntax coloring.
Click OK.
=====================================
I hope that helped,
Iain.
|
|
|
|
|
Aah... works like a charm
Thankz
Don't think you are, know you are...
|
|
|
|
|
I have derived a class from CButton and I have
overridden OnPaint and OnDraw methods in order
to change the control appearance.
This class work without problems if the custom
control is placed in a CDialog window.
When I place my control in a CDialogBar window,
my class does't work: OnPaint is never called.
I have also used the Invalidate method for the
CDialogBar window and for the custom control but
the WM_PAINT message doesn't reach my control.
How can I solve this problem ??
I have also tried to call the OnPaint method of
the CDialogBar window through its parent window
and I have had another problem. The fllowing code
fails when I try to create a CPaintDC object:
void CGradHistogram::OnPaint()
{
CRect rectUpdate;
CBitmap* pOldBitmap;
CPaintDC dc(this); <<<<<<<---- FAILS HERE
CRect l_crctGraphic;
if(!m_boDcInitialized)
{
GetClientRect(&l_crctGraphic);
// Creates the memory device context and the bitmap
if(m_pdcMemory->GetSafeHdc() == NULL)
{
CClientDC ClientDc(this);
m_pdcMemory->CreateCompatibleDC(&ClientDc);
m_pBitmap->CreateCompatibleBitmap(&ClientDc, l_crctGraphic.Width(),
l_crctGraphic.Height());
m_pdcMemory->SetMapMode(MM_TEXT);
}
else
{
AfxMessageBox(_T("Cannot create DC!!!"), MB_OK | MB_ICONEXCLAMATION);
}
m_boDcInitialized = TRUE;
}
dc.GetClipBox(&rectUpdate);
pOldBitmap = m_pdcMemory->SelectObject(m_pBitmap);
m_pdcMemory->SelectClipRgn(NULL);
m_pdcMemory->IntersectClipRect(&rectUpdate);
OnDraw(m_pdcMemory);
dc.BitBlt(rectUpdate.left, rectUpdate.top,
rectUpdate.Width(), rectUpdate.Height(),
m_pdcMemory, rectUpdate.left, rectUpdate.top,
SRCCOPY);
m_pdcMemory->SelectObject(pOldBitmap);
}
Does someone can help me ???
Thanks a lot !!!!
|
|
|
|
|
what's the equivalent of load icon for text file?
i have an array of character strings in text files.
name1@myserv.com
name2@myserv.com
name3@myserv.com
name4@myserv.com
name5@myserv.com
name6@myserv.com
...
...
I wish to include the file as application resources for my MFC dialog app. During construction of the dialog class, i want to load this file, line by line and put the email address into a character array.
For icons:
HICON hListIcon[6];
hListIcon[0] = AfxGetApp()->LoadIcon(IDI_ICON1);
hListIcon[1] = AfxGetApp()->LoadIcon(IDI_ICON2);
hListIcon[2] = AfxGetApp()->LoadIcon(IDI_ICON3);
hListIcon[3] = AfxGetApp()->LoadIcon(IDI_ICON4);
hListIcon[4] = AfxGetApp()->LoadIcon(IDI_ICON5);
hListIcon[5] = AfxGetApp()->LoadIcon(IDI_ICON6);
Can I do something similar for text file?
Thanks
norm
|
|
|
|
|
Not sure I understand. Two things:
a) if you wish your text strings not to be part of a text file but part of your application's resource: use LoadString().
b) if you wish your text strings to be part of a normal text file: honestly, seek advise in any book about C programming, C++ programming, MFC, etc etc. This is a very basic issue that is covered everywhere.
|
|
|
|
|
a) if you wish your text strings not to be part of a text file but part of your application's resource: use LoadString().
thanks, but entering 10k entries into the string table manually?
b) if you wish your text strings to be part of a normal text file: honestly, seek advise in any book about C programming, C++ programming, MFC, etc etc. This is a very basic issue that is covered everywhere.
yea man, that's not what i'm asking neither. but nevermind.
norm
|
|
|
|
|
Hi, everyone!
We are beginning a project, and we want to use VSS
to manage source codes.
I am a beginner of VSS. So I want to know where can I
find some step by step guides on VSS?
Cheers,
Georhe
|
|
|
|
|
I would think the User's Guide is the best place to look.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Thanks, Bhavnani pal!
Where can I find the User's Guide as
you mentioned?
Cheers,
George
|
|
|
|
|
It came with my retail copy of VSS. A brief overview of the product is available here[^].
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Thanks, Bhavnani pal!
I have read the article you mentioned. I think it
just contains general information of VSS and does
not teach me how to use the software.
I want to get some guides that teach me how to use
VSS step by step.
Can you help?
Cheers,
George
|
|
|
|
|
I know the ip address of a host and i want to know the name of that host. For this purpose i am using following code:
<code>struct hostent *hp;
unsigned int addr = inet_addr(m_strHost);
hp = gethostbyaddr((char *)&addr,4,AF_INET);
if (hp == NULL )
{
printf("\n Failed: %d",WSAGetLastError());
}
else
{
printf( "%s\n\n", hp->h_name );
}</code>
It is working fine for my LAN that uses ip address of type 192.x.x.x. But the problem occurs when i give the ip address of host over internet. As such sometimes gethostbyaddr is successful and in most cases it fails. It fails with error 11004 (i.e A blocking Windows Socket 1.1 call was canceled through WSACancelBlockingCall)
Strange that it is happening in office and not at home. Any idea ??? Or any other alternative way to determine host name when ip address is known ???
Strange that it is not failing in all cases. For example, the ipaddress of yahoo.com is: 64.58.79.230. If i give this ip address then, the program runs successful and the hostname returned as: w1.rc.vip.dcx.yahoo.com
But if i give the ip address: 207.219.70.31 (which is that of codeproject.com), then i get error 11004, and gethostbyaddr returns NULL
|
|
|
|
|
Shamoon wrote:
hp = gethostbyaddr((char *)&addr,4,AF_INET);
Hm... better to make a sizeof(addr) instead of putting 4 there...
Shamoon wrote:
It fails with error 11004 (i.e A blocking Windows Socket 1.1 call was canceled through WSACancelBlockingCall)
Hm... in my book 11004 is:
11004—WSANO_DATA
No data record of the requested type found. This error is also associated with gethostbyname and gethostbyaddr. It indicates that the supplied name was valid but that no data record of the requested type was found with it.
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Hi,
I am developing ATL EXE server (multithreaded) which contains std::map that i used to store the data of type structure. This std::map will be accessed by clients (ASP web application) via interfaces provided by the ATL EXE server:
struct ScheduledDevice<br />
{<br />
CComBSTR RefID;<br />
CComBSTR Name;<br />
DATE StartTime;<br />
DATE EndTime;<br />
int Status;<br />
long Command;<br />
};<br />
<br />
typedef map<BSTR, ScheduledDevice> SCHEDULELIST;<br />
SCHEDULELIST m_Schedule;<br />
<br />
HRESULT CMonitorDeviceThread::Add(BSTR DeviceName, DATE StartTime, DATE EndsTime, BSTR RefID)<br />
{<br />
ScheduledDevice obj;<br />
<br />
obj.Name = DeviceName;<br />
obj.StartTime = StartTime;<br />
obj.EndTime = EndsTime;<br />
obj.RefID = RefID;<br />
obj.Status = bookOpenStatus;<br />
<br />
EnterCriticalSection(&cs); <br />
m_Schedule[obj.RefID] = obj;<br />
LeaveCriticalSection(&cs);<br />
<br />
return S_OK;<br />
}<br />
<br />
HRESULT CMonitorDeviceThread::Cancel(BSTR RefID)<br />
{ <br />
SCHEDULELIST::iterator m_Iterator;<br />
<br />
EnterCriticalSection(&cs); <br />
if( ( m_Iterator = m_Schedule.find( RefID ) ) != m_Schedule.end() ) {<br />
<br />
if ( (*m_Iterator).second.Status == bookExecuteStatus )<br />
return E_FAIL;
<br />
m_Schedule.erase( m_Iterator ); <br />
<br />
} else<br />
return E_INVALIDARG;
LeaveCriticalSection(&cs);<br />
<br />
return S_OK;<br />
}
At different ATL EXE server thread I will continuosly read and modify the std::map (every 2 seconds).
SCHEDULELIST::iterator m_Iterator;<br />
<br />
EnterCriticalSection(&cs);<br />
<br />
for ( m_Iterator = m_Schedule.begin(); m_Iterator != m_Schedule.end(); m_Iterator++ )<br />
{ <br />
<br />
SYSTEMTIME dtStartTime, dtEndTime, stCurDate;<br />
<br />
VariantTimeToSystemTime( (*m_Iterator).second.StartTime, &dtStartTime );<br />
VariantTimeToSystemTime( (*m_Iterator).second.EndTime, &dtEndTime );<br />
GetLocalTime(&stCurDate);<br />
<br />
CHighTime bookStartTime( dtStartTime ); <br />
CHighTime bookEndTime( dtEndTime ); <br />
CHighTime curTime( stCurDate ); <br />
<br />
CHighTimeSpan sDiffStartTime = bookStartTime - curTime;<br />
CHighTimeSpan sDiffEndTime = bookEndTime - curTime;<br />
<br />
long diffStart = sDiffStartTime.GetTotalMinutes(); <br />
long diffEnd = sDiffEndTime.GetTotalMinutes(); <br />
<br />
if ( ( diffStart == 0 || ( diffStart >= -5 && diffStart <= -1 ) ) && <br />
<br />
(*m_Iterator).second.Status == bookOpenStatus ) {<br />
<br />
(*m_Iterator).second.Status = bookExecuteStatus;<br />
<br />
}<br />
<br />
<br />
if ( ( diffEnd == 0 || ( diffEnd >= -10 && diffEnd <= -1 ) ) && <br />
<br />
(*m_Iterator).second.Status == bookExecuteStatus ) {<br />
<br />
<big>m_Schedule.erase( m_Iterator );</big> <br />
<br />
}<br />
<br />
<br />
}
<br />
LeaveCriticalSection(&cs);
But somehow when I run the application (server and clients) the ATL EXE server just crash! I think the problem occured at std::map.erase method.
I dont how to replace this statement since I need to check all items in std::map to do the validation (get the StartTime/EndTime and compare it with current time).
For info, I've add the std::map item using BSTR unique key (ex: 124568798314). This key represent data in my database application.
Thank u very very much in advance . Any advice, help and suggestions strongly aprreciated.
Regards,
newbie
|
|
|
|
|
once you call erase, the iterator becomes invalid.
erase will return an iterator to the next item.
so your loop looks something like this
for (it=stuff.begin();it!=stuff.end();)
{
bool bKeepThisOne=SomeCondition(it);
if (bKeepThisOne)
++it;
else
it=stuff.erase(it);
}
|
|
|
|
|
I am trying to connect to an SQL server database using the OLE DB templates but am getting above error when linking. The code causing the error is:
hr = m_srcProduct.OpenWithServiceComponents(CLSID_SQLOLEDB, &initStd, 1);
//(m_srcProduct is a CDataSource object)
I have sqloledb.h included in stdafx.h, it has the declaration for CLSID_SQLOLEDB but it is declared extern which I think may be the problem....
//----------------------------------------------------------------------------
// Provider-specific Class Ids
#ifdef DBINITCONSTANTS
// Provider CLSID {0C7FF16C-38E3-11d0-97AB-00C04FC2AD98}
extern const GUID CLSID_SQLOLEDB ={0xc7ff16cL,0x38e3,0x11d0,{0x97,0xab,0x0,0xc0,0x4f,0xc2,0xad,0x98}};
how to fix?
|
|
|
|
|
I have an SDI application with multiple views available. Each view is derived from CFormView and is specified with a unique dialog ID.
My question is how do I change the view from one view to a user select one? I have options off of the menu bar that the user selects, this puts all the view changes inside my CMainFrm class. I don't want to destroy the original view that the application starts with, but after that all of the new views can be destroyed after they are used and moved to a new one.
Any help is appreciated.
-Eric
|
|
|
|
|
|
Anatari,
Thanks for the help. I am having one problem though. When I goto create my new view using te Create method I get a compile error of "Create: cannot access protected member declared in class CFormView"
Here is what I am attempting per the article you suggested.
if(!m_pMyView) MyView is a class derived from CFormView
{
m_pMyView = new CMyView;
m_pMyView->Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, CFrameWnd::rectDefault, AfxGetMainWnd(), AFX_IDW_PANE_FIRST+1, NULL);
}
I am doing this in the OnNewDocument of my Document class. Any ideas why I get this error? I have taken the constructor and destructors of my new Vew class and made them public and removed all the DECLARE_DYNCREATE and IMPLEMENT_DYNCREATE macros from the header and source files of the class.
-Eric
|
|
|
|
|
You have to override the create method in the CFormView derived class you're trying to show
W. Zayas
|
|
|
|
|
Consider ShowWindow().
Kuphryn
|
|
|
|
|
How do I open a new document in a MDI app without using CView::OnFileNew(). The app supports multiple doc's and I want to be able to open new one's from anywhere. I am sure it is simple. Thank you in advance.
|
|
|
|
|
One solution is CStdioFile.
Kuphryn
|
|
|
|