|
Hi everyone,
I'm trying to load a resource (mp3 file) into global memory so other apps can access the resource.
I use the combination of FindResourceEx/LoadResource/LockResource (it works perfect) and i'm able to get the pointer to the data but it's useless since i don't have access to the size of the resource so, apps don't know how many bytes to read. What can i do to get the data size???
Thanks in advance.
|
|
|
|
|
Use SizeofResource on the handle that you get from FindResourceEx
1. I will develop myself to the maximum of my potential in all ways
2. I will look for the good in all people and make them feel worthwhile.
3. If I have nothing good to say about a person, I will say nothing.
4. I will always be as enthusiastic about the success of others as I am about my own.
5. I will always remain loyal to God, my country, family and my friends - Chuck Norris
Ernest Laurentin
|
|
|
|
|
|
Using Visual C++ 6.0 MFC in SDI application
I want to setup an SDI program where the user can switch between client views (two initially and as I add more things possibly switch between more views). I found example code where I could do this using default client windows with no scrolling, but I don't understand how to set it up so that all the client views have scrolling capability. In a book that explained how to do this, they used non-scrolling views. But I can't use that code because it gets the active view and then loops through views of different classes comparing view classes. That code only works for views of CView type and not for views of CScrollView type. Any suggestions on how to do this?
Thanks ahead of time
modified on Sunday, May 25, 2008 7:05 PM
|
|
|
|
|
What is the solution of the diamond problem of Inheriting Classes.
A class is inheritting from 2 base classes and both the base classes have a function/method with the same name. From the object of the child class how we can call a function of the one base class.
|
|
|
|
|
If the functions have the same name but they get different parameters... only the function that fits the parameters should be called.
Function (int Par1, CString Par2);
Function (double Par1, int Par2);
is not possible to call both at once although they have the same name.
If both functions get the same number and typ of parameters, in the same order... then let's wait to another explanation from the high level users and I will learn it as well
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Hope you are aware of run time polymorhism.
Keep the same name function/method as virtual function in the base class. For the derived class object pointer allocate the corresponding base class (whose function needs to be invoked) then call the function resulting the corresponding base class get invoked. See below to make things clear
class A
{
public:
virtual void show(){cout<<"Class A invoked"};
}
class B
{
public:
virtual void show(){cout<<"Class B invoked"};
}
class C: public A, public B
{
}
main()
{
C* ptr = new A;
ptr->show();
C* ptr1 = new B;
ptr1->show();
}
|
|
|
|
|
Muhammad Zeeshan wrote: A class is inheritting from 2 base classes and both the base classes have a function/method with the same name.
The class structure is as follows?
Base1 Base2
\ /
\ /
\ /
Derived
If this is the class structure, then its not a classic C++ diamond problem.
Muhammad Zeeshan wrote: From the object of the child class how we can call a function of the one base class.
Just prefix the base class name before the call. See the code snippet.
Derived DerivedObject;
DerivedObject.Base1::CommonFunction();
Derived* pDerivedObject = new Derived;
pDerivedObject->Base1::CommonFunction();
Does this solve your problem? Or is it something else?
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Use virtual public for deriving classes.
|
|
|
|
|
scope resolution operator [::]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/codeProject$$>
|
|
|
|
|
hi
what is the possible ways to link two diallog boxes together.
i mean if i press a button in dialog A it would move to dialog B.
i had problems with this ..espically if i used a bitmap dialog rather than CDialog...
any suggestions...
reealy ..any kind of help will be appriciated
thank u all
|
|
|
|
|
Do you want to move the button from one dialog to another? Or the whole content from one dialog to another?
If the first one (by the second is also a way to do it) you have more than one possibility. The most dinamicall is to create the controls dinamically hen and where you need them. The other one with less code to implement is to create the button in both dialogs and just make them visible or invisible when you need it, in example:
m_LocalButton.ShowWindow (FALSE);
pOtherDialog->m_button.ShowWindow (TRUE);
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
thank u for ur reply
actually what i mean is how to call one dialog from the other ... lets say for example ..if i have any kind of operation in one dialog and the result should appear on another dialog ...so what i need exactly is with a press of a button ...the next dialog appear(pop up) or whatever u wanna call it...
i appriciate ur help
thank u
|
|
|
|
|
lahom wrote: if i have any kind of operation in one dialog and the result should appear on another dialog
Then just call the other dialog when you press in the button in either Modal or Modalless way (according to your needs), but for both... once you have called it you can access its public variables, so if you want to send anything to the second dialog, you have to have a variable/struc/class or whatever you need fitting it there.
One basic example:
OnPressButton ()
{
CSecondDialog myDialog;
myDialog.m_varResult = your_calculation_result;
int nReturn = myDialog.DoModal ();
}
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
ok
this works pretty good on a dialog based on CDialog..
I am creating a dialog based on class named: CBitmapDialog..
if I use this way of DoModal()…its not working properly
so what can I do about this … is there any other ways???
thank u
|
|
|
|
|
Modalless call of dialogs. There already are some answers for that here in forum.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Trying to connect (Open) to database with connection string retrieved using GetConnect.
I get an error message telling me that the Open failed, but the file path is different than the one I sent in Open function.
My application and database are in different subdirectories and it should not be a problem.
Could this be an ODBC problem? Perhaps I need new ODBC driver version?
I am running VC6.0 with Access 2000 and no, upgrading to anything else is not an option. Please refrain from comments like that.
Here is the code snippet:
// build database
m_CFD2008Doc->m_pFDDatabase = new CDatabase();
VERIFY(m_CFD2008Doc->m_pFDDatabase );
// set connect string
CString strConnect =
"ODBC;DSN=MS Access Database;DBQ=K:\0 FD2008\Database\db2.mdb;DefaultDir=K:\0 FD2008\Database;DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;";
if(! m_CFD2008Doc->m_pFDDatabase->Open(NULL,FALSE,FALSE, strConnect,TRUE ))
{
TRACE(" Failed to open %s database ", strConnect);
}
Error message received:
Could not find file "K:\0 FD2008\V1\FD2008\.mdb"
Thanks for your help
Vaclav
PS Why is this editor having problem accepting dereference symbol "->" in text?
A dummy fell for the oldest trick in C not including double \\ in the string. Also the last parameter in Open must be FALSE.
<div class="ForumMod">modified on Sunday, May 25, 2008 12:48 PM</div>
|
|
|
|
|
Did you try "\\" in string literal instead of "\" ?
|
|
|
|
|
Thanks, feel like an idiot for falling for the oldest trick in the C programming!
Now I get that my ODBC driver does not support dynasets!
And this is Access 2000 ! I hope I can fix that.
Thanks again.
Vaclav
|
|
|
|
|
|
Real nice article.
I think I got the access (Open) figured out now I am struggling with writing to database. Getting Invalid descriptor index and it is driving me nuts to figure it out.
The books say do AddNew, do your ads and then Update for dynaset.
But it keeps failing with this cryptic error. Something about columns numbers not proper.
But it fails on first add!
Vaclav
|
|
|
|
|
That's pretty much much it...
pMyRecordset->AddNew();
pMyRecordset->m_sColumn1="SomeData1";
pMyRecordset->m_sColumn2="SomeData2";
pMyRecordSet->Update();
How are your recordsets bound? Did you use the wizard to bind them or are you attempting to dynamically bind them?
|
|
|
|
|
I used wizard to initially build the CRecorset class and when I change field I use Update Columns and Bind All.
What bugs me - I have no feedback during Bind All and the button stays active - does not return back to "normal". So I really do not understand or see what is happening.
I vaguely remember similar problem and it had to do something with column order. There are few reference on the internet to that effect. But it does not make sense - since it fails same way if I select individual columns or just do SELECT *...
My last attempt is to use single column table and see if I can make it work.
There is something simple and stupid missing.
Vaclav
|
|
|
|
|
I was able to reproduce the "invalid descriptor index" by messing up my column index alignments in the "DoFieldExchange" and Constructor sections of my recordset class.
I'm not sure if that helps you find the problem but for what it's worth.
|
|
|
|
|
I think you found it. Me being old - today is my 65 b-day - I just did not remember the details.
Vaclav
|
|
|
|