|
Has anyone got samples of how to store an image into a SQL Server database.
I'm trying to use C++ and ATL OLEDB. The accessor maps the column to as
BLOB_ENTRY(2, IID_ISequentialStream, STGM_READ, m_image)
and I can load an image using the OleLoadPicture to store it in an IPicture interface. Now I need to be able to get this into the database.
I have tried to change the map to an IStream as it inherits from ISequentialStream
BLOB_ENTRY(2, IID_IStream, STGM_READ, m_image)
then use the IPicture::SaveAsFile(m_image,...) this doesn't work because the m_image pointer is NULL to begin with.
I have tried other methods using IStream::Write, etc. but the SetData or INsert always fails.
|
|
|
|
|
Hi everyone,
I need help with changing a window name at runtime and have browsed the internet to find what I'm looking for without much luck until now I hope!
What I need is C++ code for a small program (without runtime files) that executes a program [gamerun.exe] and than changes the name of a certain window. This is what I have come up with so far:
HWND hwnd = ::FindWindow(NULL, "OriginalNameOfWindow");
if(hwnd)
{
CWnd* wnd = CWnd::FromHandle(hwnd);
wnd->SetWindowText("NewNameForOriginalWindow");
}
Would anyone be willing to help me converting this code into a working program? I am willing to pay a fee for solving my problem!
Thanks in advance,
PEMG
----------------------
MS Windows ME
MS Visual C++ 6.0 Pro
----------------------
|
|
|
|
|
Here's what I did step by step:
1: Created a new MFC AppWizard.EXE project (dialog based)
2: Compiled the program and closed it again
3: Selected the dialog from the register
4: Added a code to OnInitDialog trough the ClassWizard
5: Compiled again and it didn't worked!
I have used this code:
// WINRename
// Source code by: TCS
BOOL CTCSDlg::OnInitDialog()
{
CDialog::OnInitDialog();
{
WinExec("gamerun.exe", SW_SHOW);
if(hwnd)
{
CWnd* wnd = CWnd::FromHandle(hwnd);
wnd->SetWindowText("Nemo Games");
MessageBox("Window name changing succeed");
}
else
MessageBox("Couldn't find Acknex window");
OnOK();
return TRUE;
}
This is the error message from Visual C++:
--------------------Configuration: TCS - Win32 Debug--------------------
Compiling...
TCSDlg.cpp
C:\Development\TCS\TCSDlg.cpp(98) : error C2065: 'hwnd' : undeclared identifier
Error executing cl.exe.
TCSDlg.obj - 1 error(s), 0 warning(s)
=================
I don't know what I did wrong maybe someone can help me out a little?
Thanks in advance,
PEMG
Windows ME
Visual C++ 6.0 PRO
|
|
|
|
|
You forgot this
HWND hwnd = ::FindWindow(NULL, "OriginalNameOfWindow");
Cheers!!!
Carlos Antollini.
|
|
|
|
|
Thanks for your help mister Antollini,
the program runs like a charm now!
CU
PEMG
|
|
|
|
|
This is the code I use right now:
BOOL CTCSDlg::OnInitDialog()
{
CDialog::OnInitDialog();
{
WinExec("gamerun.exe", SW_SHOW);
HWND hwnd = ::FindWindow(NULL, "Gamestudio");
if(hwnd)
{
CWnd* wnd = CWnd::FromHandle(hwnd);
wnd->SetWindowText("Nemo Games");
wnd->SetIcon(IDI_NEON);
MessageBox("Window name changing succeed");
}
else
MessageBox("Couldn't find Acknex window");
OnOK();
return TRUE;
}
but the program couldn't find the Gamestudio window because it isn't loaded yet. How do I put a WAIT (seconds) into the code seen above, any ideas?
Thanks in advance,
PEMG
|
|
|
|
|
You have Two solutions.
One- Execute the program with WinExec and make a while until you get the handle.
HWND hwnd = NULL;
while(hWnd != NULL)
{
hwnd = ::FindWindow(NULL, "Gamestudio");
Sleep(500);
}
Two-
Using CreateProcess();
STARTUPINFO StartupInfo = {0};
PROCESS_INFORMATION ProcessInfo;
StartupInfo.cb = sizeof(STARTUPINFO);
if(CreateProcess(NULL, lpstrCommand, NULL, NULL, FALSE,
0, NULL, (LPCSTR)lpstrCurrentDirectory, &StartupInfo, &ProcessInfo))
{
WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
}
else
{
return FALSE;
}
The WaitForSingleObject wait for the process Infinitly, but you can use milliseconds, because if the application don't start your program wait for ever in that point.
Good Luck!!!!
Carlos Antollini.
|
|
|
|
|
Thanks for your reply I will try both solutions and let you know the results. Furthermore I will put your name inside the credits & copyright next to TCS!
Best regards,
PEMG
|
|
|
|
|
I got the code half working now but there are still some problems that need to be solved before the renaming process works.
1: how to get the window ontop all other windows?
2: how to end the program when the process is done?
This is the source code of the program so far:
/////////////////////////////////////////////////////////////////////////////
// CTCSDlg message handlers
// Removed Sleep(9000); (for testing)
BOOL CTCSDlg::OnInitDialog()
{
CDialog::OnInitDialog();
{
WinExec("gamerun.exe -wnd", SW_SHOW);
HWND hwnd = NULL;while(hwnd != NULL){ hwnd = ::FindWindow(NULL,"Gamestudio"); }
if(hwnd)
{
CWnd* wnd = CWnd::FromHandle(hwnd);
wnd->SetWindowText("Nemo Games");
MessageBox("Window caption renamed");
}
else
MessageBox("Couldn't find window");
OnOK();
return TRUE;
}
|
|
|
|
|
1-With ::SetWindowPos(); Using HWND_TOPMOST.
2-You need to get the hProcess, of the program, for this is better to start the program Gamestudio with ::CreateProcess(). With this function is Easy to get the hProcess, then using the function ::GetExitCodeProcess() you will can get the satus of your application.
Cheers!!!
Carlos Antollini.
|
|
|
|
|
Many thanks for your help mister Antollini,
The program I call it RAW (R)ename (A)cknex (W)indow is getting better and better. I have found a way to change the icon of the dialog as well and with this last piece of code the program is finished!
Best regards,
Patrick Grijsen
PEMG
ps: I lost my login stuff...
|
|
|
|
|
You could simply send the WM_QUIT Message with SendMessage() to the Window
Handle.
|
|
|
|
|
Has anyone used ServerXMLHTTP (like XMLHTTP, but not based on WinInet, comes as part of MSXML3)? This class seems to be the one I want, but I find very sparse documentation on it. Can anyone give an example of how to create an onreadystatechange callback function for it in C++. There is a get_status function, but I can't find a list of what the possible status values are or what they mean. Has anybody had any experience with this class? Thanks for any help.
|
|
|
|
|
Heya,
The ServerXMLHTTP is a nice component, but the onreadystatechange() should not be used in VB or C++ compiled components, it is developed for use in scripting components.
The Status propery is standard HTTP status codes (200, 404, 500 etc).
I've tried it a couple of times in both scripting and component environments:
In scripting environments (Internet explorer...) it works great with asynchronous calls and in VC++ synchrounous calls works fine..
/WW
|
|
|
|
|
Hi!
I'm currently puzzling how to make a viewer that is fast on its update to the display. And I also want to be able to switch view between an ascii and hex view.
I currently working on comport terminal, which shall show incoming data either as ascii or hex view (user selectable) and able to transmit data which are typed to the view window.
I'm thinking of buffer for the incoming and typing data and then make a viewer on that buffer and only update visible part of the buffer to the view.
Is there any out there that can help.
I could like if some one made an article about different technics how to update a text view fast.
Regards,
Haraldur
|
|
|
|
|
I have a program that displays Ascii-Hex-Decimal view of input text. you can easily add file loading part. only send me you mail address and get it...
Cem
|
|
|
|
|
Deal all
How can I get the MAC-adress from a host computer?
Thanks
|
|
|
|
|
Deal all How can I get the MAC-adress from a host computer? Thanks
Subject:
Text:
Signature:
Insert a smiley: Deal all How can I get the MAC-adress from a host computer? Thanks
Subject:
Text:
Signature:
Insert a smiley:
Your Name:
E-Mail:
Notify me by e-mail if someone answers this message
Your Name:
E-Mail:
Notify me by e-mail if someone answers this message
|
|
|
|
|
any constructive idea/discussion is warmly welcome!
i love this site!@
|
|
|
|
|
I need source code to convert rtf file to html file, C++ code be helpful.
|
|
|
|
|
Why not just use Word or Frontpage?
Albert van Peppen
|
|
|
|
|
Dear all,
Is there any body who can teach me to write a program to print a barcode. It's functions are
1. INPUT: EAN13, UPC, CODE128 A/B/C strings
2. OUTPUT: barcode objects that we can arrange to print out with A4 size paper.
KY PHAM
|
|
|
|
|
Get the 'Free 3 of 9' font and use it.
Works great for all of my barcode-apps..
There are other fonts available for other barcode standards, but most of them are commercial.
Albert 'The Mad Butcher' van Peppen
|
|
|
|
|
Thank you very much for your help. I'll try it. Pls send me some new information if when you have.
KY PHAM
|
|
|
|
|
How can I check if a UDP port is connectable or not. I know there is no "connection" actually going on but is there a way to understan if a port is listened by a server process on winsock ? As far as I know it is possible on Unix. If you know how to do this can you post a code sample.
Orcun Colak
orcuncolak@yahoo.com
|
|
|
|