|
Hi!
I need to be able to launch a viewer for a given file from my application (Win32/MFC/C++). Ideally I'd like to present the user with choices similar to the "Open With..." feature of the explorer shell.
I tried SHGetFileInfo but it keeps returning 0 for the flag SHGFI_TYPENAME (failure).
So I assume there's two part in my quest:
1- Find the type (mime type?) a given extension (I don't necessarily have the file created yet -- i.e. I'd like the user to be able to choose before creating the file)
2- Find a list of suitable applications (path, "user friendly" name) that can open that mime type.
I seems like I could just go and fish the info from the registry, but would that work on any windows version?
Regards
R/
|
|
|
|
|
ralfoide wrote:
I could just go and fish the info from the registry
seems like the only way.
Hush,hush...
thought I heard you call my name now.
Kula Shaker.
Amit Dey
Latest articles at CP - Writing Word addins
Office addin
|
|
|
|
|
Hi everyone,
Just a quick question. Is there a way to display binary when formatting a string? I know %d is decimal, %X is hex....is there one that even exists for binary?
Jimmy
Just cause I am 15, doesn't mean I'm dumb! (I'll really be 4 on Feb. 29...the year 2004)
|
|
|
|
|
There isn't a ready-made format specifier like %b that will format an integer in binary. You'll have to brew your own by walking the bits.
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
NewHSKid wrote:
...is there one that even exists for binary?
No, you'll need to roll your own.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
There are several ways. Here are a few.
The example below will display the binary representation for the decimal 100. In addition to '#including' <bitset>, you'll also have to '#include' <limits>
cout<<"\n 100: " <<bitset<numeric_limits<unsigned int>::digits>(100)<<endl;
the="" example="" below="" will="" also="" display="" the="" binary="" configuration="" for="" decimal="" 85.
cout<<"\n="" 85:="" "="" <<bitset<8="">::bitset(85) <<endl;
there are="" some="" subtle="" differences="" between="" the="" first="" example="" and="" second,="" but="" biggest="" is="" that="" in="" second="" you="" interested="" only="" having="" eight="" bits="" to="" represent="" value,="" whereas="" you'll="" get="" 32="" value.="" iow,="" can="" restrict="" number="" of="" want="" have="" representing="" value="" you're="" displaying.
here's="" one="" for="" letters.="" it="" will="" show="" binary="" representation="" letter="" 'a'="" using="" 8="" bits.
cout<<"\n="" \"a\":="" "="" <<bitset<8="">('A') <<endl;
lastly, here's="" one="" to="" show="" a="" string="" of="" letters="" (e.g.="" "abcd").
bitset<32=""> Ltrs = bitset<numeric_limits<unsigned int>::digits>('ABCD');
cout<<"\n \"ABCD\": " <
|
|
|
|
|
Hi!
How can i determine that the pointer is pointing to a valid memory address??
e.g:
consider
class CTest
{
public:
void Release()
{
delete this;
}
};
CTest *pTest = NULL
pTest = new CTest();
pTest->Release();
If you look at the last statement i.e pTest->Release(); , the memory poionted by pTest is deleted, but pTest still contains some value. I want to determine whether the value in pTest is a valid address or not ? How can i do so ?
N.B, I've read somewhere that in MFC the is a function something like AfxIsValidAddress() , but i would prefer a non-mfc solution
|
|
|
|
|
You can use one of several Win32 APIs to check the validity of a pointer: IsBadCodePtr() , IsBadReadPtr() , IsBadStringPtr() and IsBadWritePtr() as well as the Huge analogs.
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Unfortunately, AfxIsValidAddress() and related functions like IsBadReadPtr() don't tell you if the pointer has been freed or not. They know if the address can be read from and/or written to. You'll just need to get into the habit of assigning NULL to the pointer after delete has been called.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
class CTest<br />
{ <br />
public: <br />
CTest** m_ptr;<br />
CTest(CTest** ptr = NULL)<br />
{<br />
m_ptr = ptr;<br />
}<br />
~CTest();<br />
{<br />
if(m_ptr)<br />
*m_ptr = NULL;<br />
}<br />
void Release() <br />
{ <br />
delete this; <br />
}<br />
};<br />
<br />
<br />
CTest *pTest = NULL<br />
pTest = new CTest(&pTest);<br />
pTest->Release();
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|
|
Shah Shehpori wrote:
How can i determine that the pointer is pointing to a valid memory address??
There is a big difference between "valid memory" and "memory that contains valid data". Unfortunately the computer can only tell you about the former. Even after you delete a pointer, the memory is not usually removed from your app's process space, so you could go on dereferencing the pointer and not cause a GPF.
As someone else said, get in the habit of setting pointers to NULL after a delete or Release() call and you'll avoid such bugs.
--Mike--
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
CP SearchBar v2.0.2 released
|
|
|
|
|
Please help me to find some Assembler IDE which work on Win32.
(Kind of VASM).
I spend much time for surfing all over WWW but links I found was broken
Code Red
|
|
|
|
|
Hi guys,
I am just starting to use DirectShow. I've managed to make it play a video in a CStatic in my dialog box. But now I want to draw something else there, like, put something on top of the video that is playing. I've tried using the device context from the CStatic but that doesn't seem to work - I guess I "gave" it to DirectShow and don't have control over it anymore. Another possibility would be to put another CStatic in front of the video playing, but that doesn't seem to work either, the video just plays over everything! Any suggestions?
|
|
|
|
|
|
am trying to load JPEG2000 (J2k) image and make use of the scalability features provided by J2k
by showing the image while loading. The tutorials clearly show that there are two possible “modes”:
- Progressive by resolution (You load the picture and it becomes sharper while loading, something
like interlaced GIF)
- Progressive by accuracy (ROI – region of interest)
I am interested in the first: “Progressive by resolution”. So I want to show the image while loading
for example if you download a 2 MB image through Modem connection.
I am looking for a exemplary implementation - does not matter in which language or platform it is running.
I would be grateful for any help.
Regards,
gicio
|
|
|
|
|
There any good beginner tutorials on making a context menu plug-in for Internet Explorer. I have come across a few articles here but none of them have the source code or the point you to MSDN to read about it. Trying to find something thats easy to follow.
Thanks!
|
|
|
|
|
If you just want to add items to the IE context menu that is easy. I imagine there is a way to replace it, but don't know how. What are you trying to do?
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
|
Thanks for the relpys. I kinda know how do add an item to the context menu (This is done through the registery) but what I would like info on is creating the DLL to grab the text thats selected and all that good stuff. Just something to get me started would be great. As an example (Not exactly but close) is just have an extra selection come up when I have selected text that says like Search for on goole then have my DLL get the text and post to google or wherever.
|
|
|
|
|
Hi. I have created a dialog called LOADS. This uses 8 radio buttons to allow the user to select the load (Hi / Low) on one of four instances of a wheelspeed transducer(WST). I therefore create an instance of LOADS in my main dialog:
LOADS WST
A second type of transducer is an Anti Skid Valve (ASV), but this has 6 instances of which I wish to set the load. The way I've implemented this is to have all six instances (12 radio buttons) on the LOADS dialog, and I pass a switch to DoModal() to tell it wether or not to disable the other two sets of radio buttons:
LOADS WST;
LOADS ASV;
if(WST.DoModal(1)!=IDOK)
return;
if(ASV.DoModal(0)!=IDOK)
return;
Then, in the LOADS functionality I can disable the unwanted radio buttons if the parameter to DoModal=1, and enable them if parameter =0;
Question: Instead of doing the above, how can I inherit a LOADS dialog so that I create a new dialog (eg LOADSASV) which I can then add the extra radio buttons to, thus replACING THE ABOVE CODE WITH:
LOADS WST;
LOADSASV ASV;
Can you help or point me to a suitable article? Thanks in advance.
Paul
|
|
|
|
|
Hi,
Im doing a project in Labview/IMAQ, but C/C++ can also be. I need to know how can it be done most effectively. I mean, It works in IMAQ in LabView, just by detecting particles, and measuring their max intercept and elongation.But there is a problem of right thresholding the original(grayscale) image. I also looked into hough transform - the demos are impressive. But there seems to be no implementation of it in Labview/IMAQ. Can you help somehow? Maybe you know where in WWW I can find some good and relatively simple Hough Transform implementation in C/Labview? Or some other way to do it. The calculation should take under a second for 2.4GHz computer - and image is big.
Thanks in advance.
Andru (CZ)
|
|
|
|
|
I have an app that is finished except for the aesthetics associated with my window resizing.
I need the windows size to be no smaller than a certain dimension and I need the height and width to always be a certain ratio.
I have built an OnSize handler, but it doesn't stop the window from resizing.
I have also tried using the WINDOWPLACEMENT structure and manually changing the values in that structure in response to the cx and cy passed to my OnSize handler, but it doesn't prevent all of my controls from resizing as the user continues to drag the window border.
How do I intercept the Window's resizing before the resize actually occurs so I can prevent the window from being resized?
|
|
|
|
|
See if something like this works:
void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
lpMMI->ptMaxSize.x = 640;
lpMMI->ptMaxSize.y = 480;
lpMMI->ptMinTrackSize.x = 640;
lpMMI->ptMinTrackSize.y = 480;
CFrameWnd::OnGetMinMaxInfo(lpMMI);
}
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
(Montgomery Burns, rubbing hands together) Excellent.........
Thanks DavidCrow! That nipped those pesky, resizing windows in the bud.
I wonder why WM_GETMINMAXINFO doesn't show up in class wizard?
Is there a way to tell VisualStudio to show all of the windows messages?
|
|
|
|
|
Terry O`Nolley wrote:
I wonder why WM_GETMINMAXINFO doesn't show up in class wizard?
Um, it does for me. Did you select the right class in the Class name: combobox?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|