|
I need to detect the installation of Windows Media Player 6.4 or greater.
Surprisingly, I have not been able to find information on this topic. Does
anyone know how to detect the presence of this player? Registry? *ocx? I am
up against a deadline and need HELP!!!!
|
|
|
|
|
You've got the right idea. I had to do the same recently with IE ( need 4 or greater ), and DirectX ( need 5+ ). I found the answer was to poke in the registry, best place is HKEY_CURRENT_USER\Software\Microsoft. Get onto some machines with earlier versions and make sure you've found a key that persists across versions & gives you the info you need, and you're away.
|
|
|
|
|
When you move your mouse over a menu item, the Status bar is updated with some text describing that emnu item. From what I can tell it comes from a string table. I either need to 1) modify the string table at run time (is that safe??) or 2) assign it to an in-memory string. Unfortuteately, I have not been able to find anything on the interaction between the two classes. Does anyone know how I can override this behavior?
Thanks.
|
|
|
|
|
Override CFrameWnd::GetMessageString() . You receive the menu item ID, and if you want to change the status bar string, just return the string to be displayed. Otherwise, call the base class version which will load the text from the string table.
|
|
|
|
|
Im New to Visual C++ but I am quite familiar with the outportb(){DOS} command etc.
Can anyone help me to interface the ports using MFC - Is it possible ? - I am trying to interface to a Micro-Controller
Any Samples would be grateful.
|
|
|
|
|
The Win32 API calls
CreateFile(...)
ReadFile(...)
WriteFile(...)
CloseHandle(...)
will get you much of what you are looking for. There is an MSDN sample called TTY which shows all of the serial port setup stuff.
I believe these commands work for parallel ports too, but I've never tried. The commands are not as low level as outportb() but they may do what you are looking for.
You may run into a problem with the LPT port as it may be expecting certain pins to be set high (as it expects a printer to be there). You will likely only have access to 8 pins on the port (2 through 9) as Windows probably won't give you access to the other 2 registers.
If you are using Windows 95 exclusively, you can use outportb() if you write a DLL.
E-mail me if you have any questions
|
|
|
|
|
If you use Win9x you can use outp() and inp() with <conio.h>.
For NT you need a Kernel-driver.
Check URL http://www.sybera.de/english/e_frame.htm
for a good free driver ->SHA basic pack.
|
|
|
|
|
Well I wanted to send 2 pictures, but I don't know how can I attach them. It won't be so easy to describe myself, but I'll try...
I implemented a NameSpace handling code in VC++6.0, without MFC. It works, but it has some problems.
1. I can show the folder's icons. These are OK, and looks like as "original" windows icons. But I use an ExtractIcon application. This app. changes many of system icons. (desktop,my computer, normal directories, shared directories, etc.) How can I ask/get/handle these icons (too)?
2. I can enumerate subfolders. But when I show them the order of subfolders are not the same as in Explorer. How can I sort them?
3. usually I got back no icons. Why? (this func. can not extract all kind of pidl-s?)
4. here's a part of my code: (instead of two pics)
How can I solve the #1, #2 and #3 questions?
// lpsf: interface pointer
// lpi: absolute pid (merged myself)
// hIconSmall: the icon what I want to get
bool ANameSpace::GetDisplayIconOf(IShellFolder *lpsf, LPITEMIDLIST lpi, HICON* hIconSmall)
{
bool _back = true;
HRESULT hres;
IExtractIcon *pxi;
// get IID_IExtractIcon interface
hres = lpsf->GetUIObjectOf(NULL, 1, (LPCITEMIDLIST*)&lpi, IID_IExtractIcon, NULL, (LPVOID *)&pxi);
if (SUCCEEDED(hres))
{
char szIconFile[MAX_PATH];
int iIndex;
UINT wFlags = 0;
hres = pxi->GetIconLocation(GIL_FORSHELL, szIconFile, sizeof(szIconFile), &iIndex, &wFlags);
if (SUCCEEDED(hres))
{
// I need only the small icon
HICON hiconLarge = NULL;
int cxIcon = GetSystemMetrics(SM_CXICON);
int cxSmIcon = GetSystemMetrics(SM_CXSMICON);
// try getting it from the Extract member fuction
hres = pxi->Extract(szIconFile, iIndex, &hiconLarge, hIconSmall,
MAKELONG(cxIcon, cxSmIcon));
}else
_back = false;
pxi->Release();
pMalloc->Free(pxi);
} else
_back = false;
return _back;
}
Thanks in advance,
---
AkelA
|
|
|
|
|
I can read all records in an EXCEL-file, but i can't EDIT / DELETE stored records.
I use CRecordset and CDatabase.
I can add records to the EXCEL-DB with
...
p_CRecSet->AddNew();
..fill datas
p_CRecSet->Update(); .
If I call
p_CRecSet->Open();
....
p_CRecSet->MoveLast(); //DB is'nt empty
p_CRecSet->Delete(); //exception
p_CRecSet->Update();
the Delete-command return an Exception (access-error).
Is this a problem of the ODBC (Jet/ISAM)-driver (support no EDIT / DELETE / SQL -> CLEAR TABLE),
or is there a wrong function-calling ?
SFR
|
|
|
|
|
I think the call to Open is accepting the default open type of CRecordset::snapshot - that would prevent deletions.
Oddly though, I think it wouldn't allow additions either - hmmm...
Try modifying the Open command to take an open type of CRecordset::dynaset... (?)
|
|
|
|
|
It's not well documented, but at least as of a few years ago, the Excel ODBC driver is read-only and doesn't support changes or updates.
This might have changed, but I spent the better part of a month trying to figure this out, and got an official response from MS that it was indeed read-only.
It would be nice if they mentioned that rather prominantly in the documentation, but they don't.
|
|
|
|
|
Hi,
I have a strange bug in something I'm working on:
The main program gets a message every few seconds from a different thread
that does ::PostMessage(MY_MSG, (WPARAM)sString, LPARAM(nNumber);
The function that handles this message in the main thread, gets the sString address correctly 99% of the times except from a unique scenario that causes the sString adderss to be cut in half - I'm getting only the LOWORD value of the address.
For example:
When running correctly, (WPARAM)sString is at 0x0172F6B8
When the bug happens it's only F6B8.
The bug happens when you cause the message to be posted twice with little time in between.
Any clues? I'm a bit helpless here...
Ori
|
|
|
|
|
I also forgot to mention one more important thing:
This only happens on Win9x\ME and not on the NT series.
|
|
|
|
|
You're probably losing part of the message due to the 16 bit nature of the Win9x subsystems. They're not completly 32 bit, and if your message happens to pass through a 16 bit subsystem, it will get truncated to 16 bit.
How are you defining MY_MSG? It should be WM_APP + some unique number (not WM_USER).
|
|
|
|
|
The MSG is defined as WM_APP + 2.
There is no other equivalent MSG value that might collide with this.
I have thought of the option of 16 BIT trancation, but if that is the case, isn't it supposed to happen more often?
It only happens on a very specific scenario, and not 100% reconstructable (Timing?).
Is there any solution for this? specifing the use of 32 bit addresses?
|
|
|
|
|
The only thing I can suggest is to use a different way of transfering your data. Perhaps a global variable or shared memory segment or even a stack.
|
|
|
|
|
Hi Ori,
I agree with the other poster who mentions that your user message definitions should start at WM_APP, rather than WM_USER. I actually start at WM_APP+0x100 just to be sure of no clash. However, I do not think this is the problem, and I don't think we can put the problem down to differences between win 9x and win nt.
The problem you described can be caused if the destruction of the sString object is not *guaranteed* to be determined by the code receiving MY_MSG in the main program. For example, allocating sString on the stack in a worker thread would be bad news. This is because you don't know if sString has been destructed when the main program gets round to pumping its message queue sufficiently to get hold of MY_MSG. On some program runs it might work - others it won't, such is the realm of multi-threaded programming.
This can be avoided by using SendMessage, which will block your worker thread until the main program has processed MY_MSG, thus guaranteeing sString points to valid memory for the duration of execution of the MY_MSG handler.
I'll give an example of how I'd do this using PostMessage. If I've got the wrong end of the stick - sorry - please post me and I'll try again - this is my first post to CodeProject.
void CWorkerThread::SomeFunction()
{
CString* pstrText=new CString(_T("Test"));
int iSomeNumber=0;
// Transfer ownership of the memory pointed to by
// pstrText to the receiver of MY_MSG, ie he who
// processes MY_MSG must do 'delete pstrText'.
::PostMessage(MY_MSG, (WPARAM)pstrText, (LPARAM)iSomeNumber);
// This thread does not control the lifetime of the
// memory pointer to by pstrText now. So...
// we mustn't delete pstrText here
// we shouldn't dereference pstrText here
// and probably should just deny all knowledge
// that *pstrText ever existed... nullify pstrText!
pstrText=NULL;
}
LRESULT CMainProgram::OnMyMsg(WPARAM wParam, LPARAM lParam)
{
// Document the fact that the memory pointed to by
// pstrText is now 'owned' by this function.
CString* pstrText=(CString*)wParam;
int iSomeNumber=(int)lParam;
// do some stuff with pstrText and iSomeNumber
// ....
// because we own pstrText, we must delete it
delete pstrText;
pstrText=NULL; // just for safety
return 0;
}
Does this help?
Mark
|
|
|
|
|
Greetings,
I have been stuck with this problem for a while and I cannot see what I'm doing wrong. I'd be grateful is anyone could point me in the right direction.
I have a class whose constructor is :
CMyClass::CMyClass() : CPropertyPage(CMyClass::IDD)
{
some stuff
}
Then I have,
BOOL CMyClass::OnSetActive()
{
static doneInit = FALSE;
BOOL bResult = CPropertyPage::OnSetActive();
if (!doneInit)
{
doneInit = TRUE;
if(m_WindowOut)
delete m_WindowOut;
m_WindowOut= new CWnd;
CRect rect1;
GetDlgItem(IDC_PROCESSED_WAVE)->GetWindowRect(rect1);
ScreenToClient(rect1);
m_WindowOut->CreateEx(WS_EX_CLIENTEDGE|WS_EX_STATICEDGE, AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW),NULL,WS_CHILD|WS_VISIBLE,
rect1,this, 1234);
CDialog::OnInitDialog();
}
return bResult;
}
where IDC_PROCESSED_WAVE is a picture control that I have on my dialog and
is where I would like to do the drawing and m_WindowOut is defined in
MyClass.h as public and as CWnd* m_WindowOut;
Finally the offending code:
void CMyClass::OnPaint()
{
int amp;
//CDialog::OnPaint();
CPaintDC dc(m_WindowOut);
CPen* pOldPen;
CPen pen(PS_SOLID,0,RGB(0,255,0));
pOldPen = dc.SelectObject(&pen);
CRect rcClient;
m_WindowOut->GetClientRect(&rcClient);
for(int i = 0; i < rcClient.Width(); ++i){
amp = (rand()% 15)% (rcClient.Height() / 2);
dc.MoveTo (rcClient.left + i, rcClient.top + (rcClient.Height()/2) -
amp);
dc.LineTo (rcClient.left + i, rcClient.top + (rcClient.Height()/2) +
amp);
dc.SelectObject(pOldPen);
m_WindowOut->Invalidate(TRUE);
}
// TODO: Add your message handler code here
// Do not call CPropertyPage::OnPaint() for painting messages
CDialog::OnPaint();
}
Unfortunately, nothing is drawn on my picture control and I don't have a
clue why. Please help if you can.
Regards
Rick
|
|
|
|
|
Hi, I tried to change the font of a label using SelectObject but it don't work. The SelectObject works if I use TextOut(...). But for label or edit, I use SetDlgItemText(..). So how to change the fonts used for edit/label or is there anything that I did it wrongly. Thanks.
code that I use
========================
HDC hDC = GetDC();
hFont = CreateFont(....)
HFONT hFontOld = (HFONT)SelectObject( hDC, hFont);
TextOut(....)
DelectObject(hFont)
SelectObject(hDC, hFontOld);
|
|
|
|
|
i think this way could work:
overwrite or go into InitDialog (WM_INITDIALOG)
and set here the font for the label.
I hope that is correct, because it's only a part of 16-bit-code-application (MFC). I believe IDC_ErrorA was a Label.
//define at the top of your cpp-file
CFont m_biggerFont; //must be are here, global in View for Paint()
void Cxx_View::OnInitialUpdate()
{
LOGFONT logfont;
CRect rect; // get edit control size
GetDlgItem(IDC_ErrorA)->GetWindowRect(&rect);
ScreenToClient(&rect); // in parent coordinate
memset(&logfont, 0, sizeof(logfont));
logfont.lfHeight = int ((rect.bottom-rect.top));
logfont.lfWeight = FW_BOLD;
switch(FontType)
{
case 0: strcpy(logfont.lfFaceName, "MS Sans Serif");break;
default: strcpy(logfont.lfFaceName, "MS Sans Serif");
}
VERIFY(m_biggerFont.CreateFontIndirect(&logfont));
GetDlgItem(IDC_BigA)->SetFont(&m_biggerFont,TRUE);
GetDlgItem(IDC_BigA)->UpdateWindow();
...
}
|
|
|
|
|
Hi!
I want to get string variables from a text file(.txt) how is this done? I want to be able to choose specific strings in the file when I know how the text file was formated.
If there's a better way using data bases and that isn't too complicated, that could work too
Thanks
/Fredrik
|
|
|
|
|
Can anyone tell me if there is a way to include non-standard text characters in a regular titlebar?
I'm looking to add some superscript text in my applications main window titlebar.
Thanks!
Frank
|
|
|
|
|
When I upgraded to Access 2000 I got the unrecognizable database format error.
Following MS's instructions, I added
AfxGetModuleState()->m_dwVersion = 0x0601;
before I opened the database. Now I can open the database,
but I crash when I try to access it. I'm using mfc shared dll. Service pack 3.
Anything else I need?
Thanks
|
|
|
|
|
Hello everyone!!!
I have a collection of existing True Type Font Resource filenames(*.ttf). My task is to install those fonts from resource files. My available tool is Win32 API only just because I am using InstallShield 5.0 scripting language.
With available resources, for me, installation is two-step job: 1) Using AddFontResource method; 2) Insertion of proper font keys and values into the registry - font key = font face text; font key value = font resource filename.
The QUESTION is: given that my font has not been installed yet, how can I obtain font face text using ONLY resource file name as needed for key name in the registry.
Please, please, please HELP!!!
Thanks a bunch ahead.
Kirill Sherman.
Stahls' Inc.
|
|
|
|
|
I have a exception class which I would want to be catch by ref only, so I declare the copy constructor private.
However, VC++ 6 refuses to compile, giving me an error an error that the exception object cannot be thrown because of an inaccessible copy constructor.
But upon checking, the copy constructor is only called when the exception object is caught by value
eg
catch(MyExceptionClass e) // only this needs the copy constructor
{}
catch(MyExceptionClass &e) // this doesn't need the copy constructor
{}
So has anyone been able to ensure the exception object is to be catch by ref only, not value??
|
|
|
|
|