|
At last I got the solution.
#define DB_S_ENDOFROWSET ((HRESULT)0x00040EC6L) //added for VC6
CDataSource dataSource;
hResult = dataSource.OpenFromInitializationString("Provider=SQLOLEDB.1;Password=****;Persist Security Info=True;User ID=*****;Data Source=myIPAddress); // Or Open using other parameters
CSession session;
hResult = session.Open(dataSource);
CCatalogs catalog;
hResult = catalog.Open(session);
catalog.MoveFirst();
while( SUCCEEDED(hResult) && hResult!= DB_S_ENDOFROWSET )
{
cout << catalog.m_szName << endl;
hResult = catalog.MoveNext( );
}
catalog.Close();
session.Close();
dataSource.Close();
CoUninitialize();
And this worked fine for me
Thanks,
Unni
|
|
|
|
|
<br />
typedef int (WSAAPI *Pconnect)<br />
(SOCKET s, struct sockaddr *name, int *namelen);<br />
<br />
<br />
int WSAAPI myconnect(SOCKET s, struct sockaddr *name, int *namelen)<br />
#define SIN(name) ((struct sockaddr_in *)(name))<br />
{<br />
struct sockaddr_in *paddr =(struct sockaddr_in *)name;<br />
<br />
char *ip =inet_ntoa(SIN(name)->sin_addr);<br />
int port =ntohs(paddr->sin_port);<br />
<br />
if (port == 101) <br />
{<br />
SIN(name)->sin_addr.s_addr = 0x0100007f;<br />
return ((Pconnect)hookconnect.pTrampoline)(s, name, namelen);<br />
}<br />
<br />
return ((Pconnect)hookconnect.pTrampoline)(s, name, namelen);<br />
}<br />
<br />
I found this function to redirect everytime application try to connect 101 port and connect localhost, but i have to listen same port as the application is, is there a way to edit this function make to connect diff. port?
thank you
|
|
|
|
|
Can't you simply redirect it to a different port just as you redirected it to a different IP?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
Like i said i found this code, and i don't know anything about C++ anything at all. that is the problem hahaha.... i believe you can but the reason is how? hahah..
|
|
|
|
|
Well, try something like this:
if (port == 101)
{
SIN(name)->sin_addr.s_addr = 0x0100007f;
paddr->sin_port = htons(PORT_NUMBER_YOU_WANT_TO_REDIRECT_TO);
return ((Pconnect)hookconnect.pTrampoline)(s, name, namelen);
}
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
|
Hi,
I have an (owner drawn) list control and handle the LVN_ODFINDITEM message. For testing purposes:
void CIndexDlg::OnLvnOdfinditemData(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLVFINDITEM pFindInfo = reinterpret_cast<lpnmlvfinditem>(pNMHDR);
*pResult = (rand() % 999) + 1;
}
</lpnmlvfinditem>
This works good when typing something inside the control.
But now I also want to have an external way to find an entry. So I places an edit control in the dialog and want to call FindItem manually:
LVFINDINFO fi;
ZeroMemory(&fi, sizeof(fi));
fi.flags = LVFI_PARTIAL | LVFI_STRING;
fi.psz = m_strWhat;
m_ctrlData.FindItem(&fi);
But in this case, my OnLvnOdfinditemData handler never gets called! I also tried sending manually with SendMessage but it did not work either.
What could be the problem?
|
|
|
|
|
- Could you use Spy++ to investigate what messages (with wparam and lparam? Not sure if Spy++ tracks those) are sent when doing an incremental search using the keyboard
- Have you verified your
FindItem call is successful with a non-virtual/non-owner data list control?
Aside from that, can't see as you're doing anything wrong
|
|
|
|
|
Hi and thank you for the help!
I tried it with Spy++ and for testing, I typed an 'a'. The message is sent:
<00004> 00070E74 S LVM_FINDITEMA iStart:-1 plvfi:0012E8D8
<00005> 00070E74 R LVM_FINDITEMA iIndex: 86
I really don't know why my message handler is not called
Niki
|
|
|
|
|
I know what is my error:
FindItem and SendMessage(LVM_FINDITEMA) only gives back the index of the found item but the control does not scroll automatically to that position.
Is there a way to implement this?
I already tried UpdateWindow() and also SetSelectionMark()...
Thank you!
|
|
|
|
|
That I can help you with
CListCtrl::EnsureVisible makes a specified item visible. CListCtrl::Scroll gives you more control over how the list control's view is altered.
|
|
|
|
|
Using Graphics DrawImage method am drawing a PNG image on button,it displays once but it is not sustaining when mouse moves on the button
|
|
|
|
|
Are you sure you have the right forum? This is for unmanaged C++.
It sounds like you might want the C# forum.
|
|
|
|
|
|
Show code,please?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Probably you're writing the button in the wrong message handler (if it is a message handler).
As already suggested by Hamid, you should post some code to obtain help.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
kiranin wrote: but it is not sustaining when mouse moves on the button
That is not a surprise. The button redraws itself when it is hovered over, clicked on, not clicked on, when it's just plain spiteful...
You need to put the drawing code in the right place.
Search the articles on codeproject for owner draw buttons. (http://www.codeproject.com/KB/buttons/[^]) and replace their drawing code with your own PNG stuff.
You may even find a PNG drawing button already done.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
Hi,
Where to best store a global object in an SDI app? In my case it's a "DatabaseManager" class for accessing an SQLite database.
First it was just a member variable of my CDocument but now I need the object in many places in my app.
So where to best store it?
* Global variable?
* Singleton object?
* Member variable of CWinApp?
* ...
One problem: I want to open the database when constructing the object, so the object may throw an "DatabaseException". For this reason a global variable as well as a singleton seem to be suboptimal to me.
Niki
|
|
|
|
|
The "member variable of CWinApp" makes the most sense to me.
HTH
|
|
|
|
|
Ok
Is it a good way to store the "DatabaseManager" class as a pointer and do a new CDatabaseManager(filepath) inside my CMyApp::InitInstance() (and an appropriate delete in the destructor)?
And then everytime I need it, just
dynamic_cast<cmyapp*>(AfxGetApp())->GetMyDatabase()
?
Thank you,
Niki
|
|
|
|
|
...or is it better to write a
extern CMyApp theApp;
in every source file needed and use theApp.GetDabataseManager() ?
|
|
|
|
|
From a strict technical viewpoint, this solution is faster to execute, and cleaner, because there is no cast involved.
I would prefer this, personally.
|
|
|
|
|
nobaq wrote: First it was just a member variable of my CDocument but now I need the object in many places in my app.
That's what the GetDocument() method is for.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
I have learned c++/MFC for several years but no obvious improvement.
suddenly I transfered to c# and .net, I have strong feeling that c# can save you much much more time compared to MFC based programming.
I am wondering why MFC is still being used now? what is the advantage? is it efficiency or flexbility compared to c# based programming?
|
|
|
|
|
I think compare is not correct but for me c++ is best language to use to write COM components also you can see we dont need to write lot of code for use of windows API but on the C# you need to more work on the C# you cant use of multiinheritance(I like it myself) on the C# you dont have header file and....for example I read a programmer said that F# is better C#.
F# code:
#light
(*sample windows forms program*)
open System.Windows.Forms
let form=new Form(Visible=true,TopMost=true,Text="Welcome")
...
...
<joke>
BTW be careful you are on the c++ form and you want to compare c++?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|