|
dereive a class from CButton as CMyButton. override the create method and pass the flags as required, then use ur button where ever cbutton is used. this way you can minimise the no of parameters passed to create a CButton.
My God is more powerfull Than Your God. (the line that divides the world)
|
|
|
|
|
Thanks for the reply, Mr. Prakash.
As my app only has two buttons needed to be push button type, I thought I could quickly "set" them in the OnInitDialog(), like following
m_StaButton.SetButtonStyle(BS_PUSHLIKE, TRUE);
m_StoButton.SetButtonStyle(BS_PUSHLIKE, TRUE);
m_StaButton and m_StoButton are DDX controls to the buttons on the dialog. As you'd expect, they don't seem to work. I am not sure if I understand why..
|
|
|
|
|
I tried searching for BS_PUSHLIKE button style, dont know wheather it exists??? but the code seems quite rite nothing wrong in it.
My God is more powerfull Than Your God. (the line that divides the world)
|
|
|
|
|
So to my understanding, I can set the button's style and it will change dynamically in my dialog, without having to destroy and re-create the button like this
CRect buttRect;
m_StaButton.GetWindowRect(&buttRect);
m_StaButton.ScreenToClient(&buttRect);
m_StaButton.DestroyWindow();
m_StaButton.Create("Start Print", WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE, buttRect, this, IDC_STARTPRINT);
maybe the method from my previous post work, I just didn't realise what BS_PUSHLIKE should look like...I will try other styles..
Thanks again
|
|
|
|
|
Yes, ( i am not sure, never tried it) your button style can be changed by setting the style....
although this method of destroying and recreating will also work.
Hey after all this is a programming language, you can do the same thing in different ways, but the best way is the effcient way.
regards,
prakash
My God is more powerfull Than Your God. (the line that divides the world)
|
|
|
|
|
How does one find out if items right clicked
is a file class or folder class?
Thank You
Bo Hunter
|
|
|
|
|
Hi Hunter,
Hope this will help you.
WIN32_FIND_DATA wFindData;
ZeroMemory(&wFindData,sizeof(WIN32_FIND_DATA));
hResult = SHGetDataFromIDList(pShellFolder,pPIDL,SHGDFIL_FINDDATA,&wFindData,sizeof(WIN32_FIND_DATA));
In this, pShellFolder is the Address of parent folder and pPIDL is the PIDL corrosponding to the selected item.
if (wFindData.dwFileAttributes && FILE_ATTRIBUTE_DIRECTORY) {
// It is a directory!.
}
else {
// It is a file!.
}
Regards
Dinesh
|
|
|
|
|
I have an exporting function in a dll and have to use a
<vector> pointer as parameter.
"
extern "C" __declspec( dllexport ) unsigned int func
(vector<int>* const vIndex)
{
for(int i=0; i<n; i++)
="" vindex-="">push_back(i);
}
"
calling application will call the function as follow:
"
....
vector<int> vIndex;
unsigned int iResult = func(&vIndex);
....
"
I am using Vstudio.net 2003
If I use MFC in a shared dll and Runtime library
with /MDd option on both DLL and calling application,
everything is fine. If I use MFC in a static library and
Runtime library with /MTd option on both DLL and calling
application, there's a problem in the vector destructor,
desctructor could not deallocate the memory.
Could someone help me? This is an emergency!!!
Thank you.
|
|
|
|
|
You've hit upon the problem and solution yourself.
If the dlls in an application are linked against the static C runtime, then any allocation/deallocation will occur in a different heap for each module. If one module tries to deallocate memory that was allocated on a different module, the heap will know nothing about it, and crash when you try and do it.
There are two main alternatives:
1. Use a shared heap, via the DLL C runtime, rather than the static one, and for MFC, this will mean using the shared MFC rather than the static ones.
2. Always ensure that any memory allocated is always deallocated in the same module. This forces you to be extremely careful with the STL, so that probably isn't a viable solution for you.
|
|
|
|
|
How to read and edit the id3 tag for a wma file?
There are functions in the windows media SDK to do it but this involves linking in to a pretty big library for what is a simple operation.
Does anyone know how to do this simply?
|
|
|
|
|
Are they really ID3 tags ? If so, heaps of code exists to do it.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
ye, but almost all the id3 tags info is for MP3 files,not for wma file. The structure is different. And maybe I haven't found the right space for wma files. If you knew some info, could you tell me? I want the info for wma files. Thanks a lot.
|
|
|
|
|
If the structure is different, then it's not an id3 tag, is it ?
I have no idea how they are encoded then.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Whatever, thanks for your kind. To speak the truth, I don't know what should them be called, but I'm used to use the id3 tag for all the format. Just the info for Title, Album, Artist, Genre, Year, Comment and Track.
|
|
|
|
|
Hello,
First things first! Is it the ID3v1 tag or the ID3v2 tag.
About the ID3v1 tag:
It is always 128 bytes long and it's located at the very end of the file. Those bytes mean the following:
0 - 2 : These bytes contain the string "TAG", if not, it's not a valid ID3v1 tag!
3 - 32 : Song Title.
33 - 62 : Artist.
63 - 92 : Album.
93 - 96 : Year.
97 - 126: Comments.
127 : Genre.
Sometimes byte 125 and 126 are the track number on the album!
More information on the ID3v1 tag can be found here[^].
about the ID3v2 tag:
It's size is variable, it can contain almost everything (even another song, lyrics, pictures...). This tag is located at the beginning of the file.
Read more about this tag here[^.
These sites helped me alot when I developed an application that needed to read those tags. I hope it does the same for you!
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
Hi,Bob Stanneveld,
Thanks for your kinds.
I have visited the site and have got some information on it. But the info is for MP3. The tag for mp3 is different for wma and ogg. I have finished the function for MP3 files and now I am working on wma and ogg files. Any suggestion?
|
|
|
|
|
Hello,
Sorry that I overlooked the fact that ID3v# tags are for MPEG encoded streams.
Since WMA stands for WINDOWS media audio, I did some searching on msdn and this[^] is what I came up with. You can find the discription, the sdk and more on it.
After googling for the OGG file format documentation, I found some interesting results here[^].
Good luck.
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
Thanks for your help. I'll study those documentation. You know, I just a newer. It maybe spend me a long time and I'm not sure whether I could finish it. But I'll try my best.
Nice to meet you. Good luck, too.
|
|
|
|
|
Glad I could help !
I'm also a newbie, 18 and got much to learn and a very long way to go
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
I am trying to create MFC-based dll that will present SDI Doc/View interface
to the user.
[my question is at the end of this rather lengthy post]
This dll will be called from Win32 application that is not MFC based (also,
this app is
written in C, not in C++).
I created MFC-based dll project (called MFCDLL) using the Wizard.
In this project I created following classes:
CPrintingDoc (derived from CDocument)
CPrintingView (derived from CView)
CMainFrame (derived from CFrameWnd)
I created an exported function in this dll:
extern "C" __declspec(dllexport) int SomeFunction(int n)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
theApp.Initialize();
return ++n;
}
My intent is that Win32 application calls SomeFunction(), and SomeFunction
initializes Doc/View environment. Related piece of code looks like this:
BOOL CMFCDLLApp::Initialize()
{
AfxEnableControlContainer();
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CPrintingDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CPrintingView));
AddDocTemplate(pDocTemplate);
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
return TRUE;
}
Essentially I replicated by hand the code that wizard generates for the
MFC-based .exe application
I also created String Table resource in this dll and added the following
string to it:
IDR_MAINFRAME TEST\n\nTEST\n\n\nTEST.Document\nTEST Document
When I start Win32 application and call SomeFunction() I get the dialog box
with message:
"Failed to create empty document",
and the view is not created.
Stepping through the code I found that the document is actually successfully
created
in function
CDocument* CSingleDocTemplate::OpenDocumentFile(LPCTSTR lpszPathName,
BOOL bMakeVisible)
This function is in file DOCSINGL.CPP (MFC source code). Document is created
in line 112:
[line 112] pDocument = CreateNewDocument();
The problem lies further in the same function, when in line 132 it attempts
to create the
frame:
[line 132] pFrame = CreateNewFrame(pDocument, NULL);
This function call returns NULL, the frame is not created, and this is why I am receiving this error message.
So my understanding at this point is that I maybe have to create this frame
window
myself somewhere in CMFCDLLApp::Initialize() before
if (!ProcessShellCommand(cmdInfo))
line (the failed attempt of frame creation is deep inside
ProcessShellCommand())
Is that right ? How would I do this ?
Or maybe I am going in the completely wrong direction - in that case please
suggest what
I need to do differently
|
|
|
|
|
Hi,
I don't have any experience with dlls. I have created a resource only dll and I want to call the resources from a different project, a SDI application. How do I so that? Please reply
|
|
|
|
|
first you need to load the resource dll using loadlibrary and get its instance handle.
Now this instance handle should be supplied to ::LoadIcon
::LoadString etc where ever it is necessary,
The resource.h file of the resource only dll should be #inclueded in ur sdi application, be carefull it may clash with ur sdi resource.h file too.
there are other apis releated to resoruce handling you can refer MSDN for that.
My God is more powerfull Than Your God. (the line that divides the world)
|
|
|
|
|
I guess this is not actually a C++ question but can someone shed some light on the meaning of these paths ( I am not even sure what they are called ).
1) . ( does this mean current dir )
2) ..\\
3) ..\\..\\
4) \somedir\debug\someexe.exe
I sometimes need these when doing a postcompile copy of a dll to a working folder. I don't like to use paths like c:\program\plugindir\ for example. I would search the net myself I just don't know what to search for.
Thanks
|
|
|
|
|
smesser wrote:
1) . ( does this mean current dir )
2) ..\\
3) ..\\..\\
4) \somedir\debug\someexe.exe
First off - notice that in 1-3, you used \\ and in 4 you used \.
Using '//' is a C/C++ language feature (double escape sequence) and not the way you would navigate directories in an OS. Using '\\' is a way to let the OS know that you are referring to a network resource - but only after the drive letter. I have never used - or seen used - '\\' to define subdirectories.
1 - current directory - current directory is OS dependent. Some OS' determine a system-wide current directory according to the last directory accessed (ie MS-DOS). Current directory may also be relative to the logged in user's last disk access.
2 - ..\\ refers to the parent directory of the current directory (see #1)
3 - ..\\..\\ refers to the parent directory of the parent directory of the current directory (see #1)
4 - Is an absolute path from the root drive of the current directory. It could also be relative to the home directory of the currently logged account/website/whatever
The relative paths could be different depending upon what permissions you have when you access the resource in question. If your server has C:, D: & E: hard drives and you have a web client whose login directory is on E:\users\joblo and there was a file E:\users\joblo\index.html then you (as a user with root acces) would access it as E:\users\joblo\index.html but he would access it as \index.html
If you used an app to access that file path and you entered \index.html, you might end up with a totally different file (most likely a file named index.html that resided on your machine's bootable hard drive).
|
|
|
|
|
Terry,
Thanks, very useful information for me.
Opps I did confuse the issue a little with the double slashes but thanks for seeing through to my real question.
Steve
|
|
|
|