|
Hi all
<code>
#include <windows.h>
HWND handle;
int main ()
{
handle = GetForegroundWindow();
SetWindowText(handle,"Hello!");
return 0;
}
</code>
When i compile my program it's not working and give me the error say
Cannot convert parameter 2 from char[7] to LPCWSTR in SetWindowText function.
Regards
-*-*-*-*-*-*-*-*-*
To Be Or Not To Be
(KARFER)
-*-*-*-*-*-*-*-*-*
|
|
|
|
|
Its SetWindowText(handle,_T("Hello!"));
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 )
|
|
|
|
|
thank's for all replays
-*-*-*-*-*-*-*-*-*
To Be Or Not To Be
(KARFER)
-*-*-*-*-*-*-*-*-*
|
|
|
|
|
You project settings are set to Unicode but you're using ANSI strings.
Steve
|
|
|
|
|
Hi,
I've a requirement to find how many database exists in a SQL Server.
I want this to be done VC++ 6.0. There is some method to do it using CDataSource, CSession, CSchemata etc but not aware of how to do it. Can any body help me out in this?
User Name, Password and Server (IP/Hostname) name will be provided as argument. I want the list all the database present in the SQL Server. This will be a small C++ program as this needs to work from SQL Server 2000 and above.
The method will be as follows
CStringArray FindDatabase(CString szHostName, CString szUserName, CString szPassword)
This method should return the list all the database instance of SQL server of the specfied IP.
Please help.
Thanks in advance.
Unni
|
|
|
|
|
Did you seeEnumerate SQL Server using SQL DMO[^]?
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 )
|
|
|
|
|
Thanks.
I thought that's obsolete technology.
I think this is possible using OLEDB. After googling i got some hints but don't know how to proceed.
I'm looking for a code snippet. Something like this - but don't know how to proceed
HRESULT hResult;
hResult = ::CoInitialize(0);
if (SUCCEEDED(hResult)){
CDataSource dataSource;
hResult = dataSource.OpenFromInitializationString(OLESTR("Provider=SQLNCLI.1;Integrated Security=SSPI;Persist Security Info=False;User ID=sa;Data Source=NEWCOMPUTER\\SQLEXPRESS"), false);
if (SUCCEEDED(hResult)){
CSession session;
hResult = session.Open(dataSource);
if (SUCCEEDED(hResult)){
// now get the list of database using CSchemata or something like that
// dont know what to do
session.Close();
printf("Success");
}
dataSource.Close();
}
::CoUninitialize();
}
Thanks,
Unni
|
|
|
|
|
Look at SYSTABLES , specifically the dbname field.
"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
|
|
|
|
|
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...
|
|
|
|