|
Hi,
I want to display load and display and image which present in the directory in VC++. I will be using menus, toolbars... Using SDI, we can get toolbars inbuilt and not much of code to be written, but I do not know how to display an Image, as there are no controls to place. Using Dialog based, there is no menus and toolbars.
I wanted to know, which is the better one to do an image processing project and also how to display and image.
Please do help.
Thanks
|
|
|
|
|
you can look for CxImage Libaray Inthis Site,very good S/W for Image Processing
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Hi,
I'm having trouble with that function. I have a block representing an RGB image with 8 bits per color value. I wanted to use the function SetDIBitsToDevice to output this image to screen. The problem is that the function returns 0 (error because 0 lines set) and GetLastError() function also returns 0. So I don't know what the problem is. Even if the image I have is screwed up I thought it should output some kind of weird thing to the screen or at least crash.
Here's my code inside OnPaint() function of ChildView:
<br />
CPaintDC dc(this);<br />
BITMAPINFO m_bitmapInfo; <br />
m_bitmapInfo.bmiHeader.biSize = sizeof( BITMAPINFOHEADER );<br />
m_bitmapInfo.bmiHeader.biWidth = m_nOutputWidth;<br />
m_bitmapInfo.bmiHeader.biHeight = -m_nOutputHeight;
m_bitmapInfo.bmiHeader.biPlanes = 1;<br />
m_bitmapInfo.bmiHeader.biBitCount = 32;<br />
m_bitmapInfo.bmiHeader.biCompression = BI_RGB;<br />
m_bitmapInfo.bmiHeader.biSizeImage = ::abs( m_nOutputWidth*m_nOutputHeight ) * 3;<br />
m_bitmapInfo.bmiHeader.biXPelsPerMeter = 100;<br />
m_bitmapInfo.bmiHeader.biYPelsPerMeter = 100;<br />
m_bitmapInfo.bmiHeader.biClrUsed = 0;<br />
m_bitmapInfo.bmiHeader.biClrImportant = 0;<br />
<br />
int val = ::SetDIBitsToDevice(<br />
dc.GetSafeHdc(),<br />
0, <br />
0,<br />
m_bitmapInfo.bmiHeader.biWidth, <br />
m_nOutputHeight,<br />
0, <br />
0,<br />
0, <br />
m_nOutputHeight,<br />
m_pImageData,
&m_bitmapInfo, <br />
DIB_RGB_COLORS );<br />
DWORD err = ::GetLastError();<br />
Thanks for the help.
|
|
|
|
|
I set m_bitmapInfo.bmiHeader.biBitCount = 32;
and the image is 8 bits per pixel. I wish it would have crashed instead of doing nothing and making it hard to debug.
|
|
|
|
|
Blast that was I was going to mension!
I found that the functions that deal with DIBs image data in this fashion tend to fail if the information is not exactly correct WITH OUT generating an error that explanes why it failed.
The GetDIBits() will also fail in the same way WITH OUT an explanation.
I do not know what you are using this for but I would just make the DIB information a member which is updated when that data is changed. That way you will not have to do all that initiation in the OnPaint() function. Of course for a simple application the drawing speed increase would not even be noticable.
INTP
|
|
|
|
|
Hi,
i try to put my small icon in systemtray, for this, i have one icon, IDI_ICON1 with two draws (one with 32x32 and the other with 16x16) but when I use Shell_NotifyIcon(NIM_ADD, IDI_ICON1) the program adapts the 32x32 icon why doesn't use the small icon directly? What I have to do?
Thanks
|
|
|
|
|
test using single icon of 16x16 and add it system tray
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
I've tried with this too, but it doesn't work. It puts on system tray the transparent icon of 32x32.
|
|
|
|
|
Yeah i tried too,here also it not working properly , i think shell_notifyicon required 32x32 for showing icon at system tray.
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Then i'll conform with the big icon
Thanks for help me
|
|
|
|
|
you r always Welcome Brother
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Looking at your example you do not have x, y and z in your new struct, just one flag called xyz_offset.
If you want different flags for x, y and z then you need to specify them in your struct.
The the check if (mystruct.x) will work just fine.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
Yes, your are correct x,y, and z don't exist in the new struct. I only showed the new (actual) struct since you said that my made up struct had a mistake in that the unsigned space: 3;
I had only put a three because that I didn't know where the 16 in the new struct had come from.
|
|
|
|
|
Hi,
I have a problem with function pointers in C++. As example;
class A
{
...
public:
double go(double (A::*f)(double, double));
double callMe(double, double);
void myFunc();
}
...
double A::go(double (A::*f)(double, double))
{
return f(1, 2); // for example
}
double A::callMe(double x, double y)
{
return x+y;
}
void A::myFunc()
{
go(&A::callMe);
}
But the compiler complains that A::f is not a function pointer?? I really can't se why. Any ideas
Thanks guys!
|
|
|
|
|
First off, I need to say that function pointers are yucky and should be avoided whenever possible.
I think the answer is:
double A::go(double (A::*f)(double, double))
{
return (*f)(1, 2); // for example
}
It's something so much nicer done with interfaces...
*sigh*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
This is untested, but change
double A::go(double (A::*f)(double, double))
{
return f(1, 2);
} to
double A::go(double (A::*f)(double, double))
{
return (this->*f)(1, 2);
} You can't call a non-static member function without specifying what the this object will be.
--
I'm Michael Dunn and I approve this post.
Vote Trogdor in oh-four!
|
|
|
|
|
I have implemented an instance of IWebBrowser2 in my application and am using IDocHostUIHandler::GetHostInfo(DOCHOSTUIINFO* pInfo) to set various properties of the web browser such as no 3D border (DOCHOSTUIFLAG_NO3DBORDER) and no scroll bars (DOCHOSTUIFLAG_SCROLL_NO). I also wish to disable the running of scripts in my instance of the browser and have attempted to use DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE. The suppression of the 3D border and scroll bars is working perfectly but the suppression of scripts is not working. Here is my implementation of IDocHostUIHandler::GetHostInfo(DOCHOSTUIINFO* pInfo):
HRESULT FAR EXPORT ZBrowser::XDocHostUIHandler::GetHostInfo(DOCHOSTUIINFO* pInfo)
{
/*
DOCHOSTUIFLAG_DIALOG = 0x00000001,
DOCHOSTUIFLAG_DISABLE_HELP_MENU = 0x00000002,
DOCHOSTUIFLAG_NO3DBORDER = 0x00000004,
DOCHOSTUIFLAG_SCROLL_NO = 0x00000008,
DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE = 0x00000010,
DOCHOSTUIFLAG_OPENNEWWIN = 0x00000020,
DOCHOSTUIFLAG_DISABLE_OFFSCREEN = 0x00000040,
DOCHOSTUIFLAG_FLAT_SCROLLBAR = 0x00000080,
DOCHOSTUIFLAG_DIV_BLOCKDEFAULT = 0x00000100,
DOCHOSTUIFLAG_ACTIVATE_CLIENTHIT_ONLY = 0x00000200,
DOCHOSTUIFLAG_OVERRIDEBEHAVIORFACTORY = 0x00000400,
DOCHOSTUIFLAG_CODEPAGELINKEDFONTS = 0x00000800,
DOCHOSTUIFLAG_URL_ENCODING_DISABLE_UTF8 = 0x00001000,
DOCHOSTUIFLAG_URL_ENCODING_ENABLE_UTF8 = 0x00002000,
DOCHOSTUIFLAG_ENABLE_FORMS_AUTOCOMPLETE = 0x00004000,
DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION = 0x00010000,
DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION = 0x00020000,
DOCHOSTUIFLAG_THEME = 0x00040000,
DOCHOSTUIFLAG_NOTHEME = 0x00080000,
DOCHOSTUIFLAG_NOPICS = 0x00100000
*/
pInfo->cbSize = sizeof(DOCHOSTUIINFO);
pInfo->dwFlags = DOCHOSTUIFLAG_NO3DBORDER | DOCHOSTUIFLAG_SCROLL_NO | DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE;
pInfo->dwDoubleClick = DOCHOSTUIDBLCLK_DEFAULT;
return S_OK;
}
Any help on this would be greatly appreciated!
Thanks!
Peter Gorgia
peter.gorgia@tradeweb.com
|
|
|
|
|
I am creating a window at run-time, using this command:
CChildFrame2* pMDIChildWnd = new CChildFrame2;
pMDIChildWnd->Create(NULL, _T("My "), WS_CHILD | WS_VISIBLE | WS_OVERLAPPEDWINDOW, rectDefault, NULL, NULL);
I've made a number of attempts to create a CCreateContext pContext, but have been unsuccessful. I think I might have to register some DocTemplate at initialization or something??
Please Help
A
|
|
|
|
|
I'm trying to create my threads, but when I go to compile this I get an error:
<br />
void CLAMsgSwDlg::StartAllThreads()<br />
{<br />
int nCount = m_lClientConn.GetItemCount();<br />
<br />
ThreadInfo *mythreadinfo = new ThreadInfo[nCount];<br />
for (int i = 0; i < nCount; i++)<br />
{<br />
mythreadinfo[i].thdIPaddress = m_lClientConn.GetItemText(i, 0);<br />
mythreadinfo[i].thdPort = m_lClientConn.GetItemText(i, 1);<br />
<br />
CWinThread* pThread = new CWinThread[nCount];<br />
pThread[i] = AfxBeginThread(myThreadFunc, &mythreadinfo[i]);<br />
<br />
HANDLE* hThread = new HANDLE[nCount];<br />
hThread[i] = pThread->m_hThread;<br />
}<br />
}<br />
<br />
UINT CLAMsgSwDlg::myThreadFunc(LPVOID pParam)<br />
{<br />
m_sConnectSocket.SetParent(this);<br />
<br />
<br />
}<br />
<br />
Can some one tell me what I'm doing wrong here. i get an error "none of the 2 overloads can convert the first parameter"
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
You did not indicate what line was in error so I can only assume it was the AfxBeginThread() statement. Yes? If so, myThreadFunc() should be a static member, or a non-class function.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thanks David, I saw that in another program that I wrote a while back. After I made the function static, I received another error.
On the same call I get an error "operator =" function is not avaliable in CWinThread.
In the MSDN is says that it returns a pointer to the newly created object. Did I not setup my pointer right?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
OK, this may help you out. Firtly make the myThreadFunc static as David says.
Then if you alter the parameter class/struct to hold a pointer to the CLAMsgSwDlg class you can call the non-static member function and therefore other member elements.
Add the following to the ThreadInfo class/struct
CLAMsgSwDlg* thdParent;
Make the alterations in bold
void CLAMsgSwDlg::StartAllThreads()
{
int nCount = m_lClientConn.GetItemCount();
<p></p>
ThreadInfo *mythreadinfo = new ThreadInfo[nCount];
for (int i = 0; i < nCount; i++)
{
mythreadinfo[i].thdIPaddress = m_lClientConn.GetItemText(i, 0);
mythreadinfo[i].thdPort = m_lClientConn.GetItemText(i, 1);
mythreadinfo[i].thdParent = this;
<p></p>
CWinThread* pThread = new CWinThread[nCount];
pThread[i] = AfxBeginThread(myThreadFunc, &mythreadinfo[i]);
<p></p>
HANDLE* hThread = new HANDLE[nCount];
hThread[i] = pThread->m_hThread;
}
}
<p></p>
UINT CLAMsgSwDlg::myThreadFunc(LPVOID pParam)
{
ThreadInfo *threadinfo = reinterpret_cast<ThreadInfo*>(pParam);
ASSERT(theadinfo != NULL);
threadinfo->thdParent->DoThreadStuff();
}
<p></p>
void CLAMsgSwDlg::DoThreadStuff()
{
m_sConnectSocket.SetParent(this);
}
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
|
How to define current directory? Actually a directory from which program started. And a back side of this: how to define whether file exist in a specified path ?
|
|
|
|
|
Take a look at "GetModuleHandle" and "GetModuleFileName"
GetModuleHandle will return a handle to the currently running app.
Use the handle in GetModuleFileName to get the path of the module...or you app.
You can also use GetCurrentDirectory().
That should do it.
Hope this helps
Tom Wright
tawright915@yahoo.com
|
|
|
|