Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old May 4th, 2008, 1:32 PM   #1
Cisnotforcookie
Newbie
 
Join Date: May 2008
Posts: 6
Rep Power: 0 Cisnotforcookie is on a distinguished road
what does undefined reference mean?

so i have this code that i found online:

c Syntax (Toggle Plain Text)
  1. // needed headers
  2. #include <windows.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <ctype.h>
  7. #include <io.h> // _access()
  8. #include <ocidl.h> // LPPICTURE
  9. #include <olectl.h> // OleLoadPicture()
  10. #include <ole2.h> // CreateStreamOnHGlobal
  11.  
  12. // these are the needed libraries
  13. #pragma comment(lib,"uuid.lib")
  14. #pragma comment(lib,"ole32.lib")
  15. #pragma comment(lib,"oleaut32.lib")
  16.  
  17. // macro
  18. #define Show(Window) RedrawWindow(Window,0,0,0);ShowWindow(Window,SW_SHOW);
  19.  
  20. // globals
  21. static HINSTANCE BCX_hInstance;
  22. static int BCX_ScaleX;
  23. static int BCX_ScaleY;
  24. static char BCX_ClassName[80];
  25. static HWND Form1;
  26. static HWND Jpg1;
  27.  
  28. // prototypes
  29. HWND BCX_Form(char*,int=0,int=0,int=250,int=150,int=0,int=0);
  30. HWND BCX_OlePicture(char*,HWND=0,int=0,int=0,int=0,int=0,int=0,int=0,int=0,int=0);
  31. STDAPI OleLoadPicture(LPSTREAM, LONG, BOOL, REFIID, LPVOID *);
  32.  
  33. void FormLoad (void);
  34. LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
  35.  
  36.  
  37. // standard main for Windows Graphics User Interface (GUI)
  38. int WINAPI WinMain(HINSTANCE hInst,HINSTANCE hPrev,LPSTR CmdLine,int CmdShow)
  39. {
  40. WNDCLASS Wc;
  41. MSG Msg;
  42. // *****************************
  43. strcpy(BCX_ClassName,"JPEG_FILE1");
  44. // ************************************
  45. // Scale Dialog Units To Screen Units
  46. // use of pixels has not been specified
  47. // ************************************
  48. RECT rc = {0,0,4,8};
  49. MapDialogRect (NULL,&rc);
  50. BCX_ScaleX = rc.right/2;
  51. BCX_ScaleY = rc.bottom/4;
  52. BCX_hInstance = hInst;
  53. // ******************************************************
  54. Wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
  55. Wc.lpfnWndProc = WndProc;
  56. Wc.cbClsExtra = 0;
  57. Wc.cbWndExtra = 0;
  58. Wc.hInstance = hInst;
  59. Wc.hIcon = LoadIcon(NULL,IDI_WINLOGO); // standard icon
  60. Wc.hCursor = LoadCursor(NULL,IDC_ARROW); // standard cursor
  61. Wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
  62. Wc.lpszMenuName = NULL;
  63. Wc.lpszClassName = BCX_ClassName;
  64. RegisterClass(&Wc);
  65.  
  66. FormLoad();
  67. // message loop
  68. while(GetMessage(&Msg,NULL,0,0))
  69. {
  70. HWND hActiveWindow = GetActiveWindow();
  71. if (!IsWindow(hActiveWindow) || !IsDialogMessage(hActiveWindow,&Msg))
  72. {
  73. TranslateMessage(&Msg);
  74. DispatchMessage(&Msg);
  75. }
  76. }
  77. return Msg.wParam;
  78. }
  79.  
  80.  
  81. // create the Windows form
  82. HWND BCX_Form(char *Caption, int X, int Y, int W, int H, int Style, int Exstyle)
  83. {
  84. HWND A;
  85. // assign a default style
  86. if (!Style)
  87. {
  88. Style= WS_MINIMIZEBOX |
  89. WS_SIZEBOX |
  90. WS_CAPTION |
  91. WS_MAXIMIZEBOX |
  92. WS_POPUP |
  93. WS_SYSMENU;
  94. }
  95. A = CreateWindowEx(Exstyle,BCX_ClassName,Caption,
  96. Style,
  97. X*BCX_ScaleX,
  98. Y*BCX_ScaleY,
  99. (4+W)*BCX_ScaleX,
  100. (12+H)*BCX_ScaleY,
  101. NULL,(HMENU)NULL,BCX_hInstance,NULL);
  102. // assign a default font
  103. SendMessage(A,(UINT)WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),
  104. (LPARAM)MAKELPARAM(FALSE,0));
  105. return A;
  106. }
  107.  
  108.  
  109. // this is the meat!
  110. HWND BCX_OlePicture(char* szFile,HWND hWnd,int id,int X,int Y,int W,int H,
  111. int Res,int Style,int Exstyle)
  112. {
  113. HWND A;
  114. HBITMAP hBitmap;
  115. DWORD dwFileSize;
  116. DWORD dwBytesRead;
  117. HANDLE hFile;
  118. LPPICTURE gpPicture;
  119. LPVOID lpPicData;
  120. LPVOID pvData;
  121. LPSTREAM pstm;
  122. LPVOID hrlp;
  123. HGLOBAL hGlobal;
  124.  
  125. // assign a default style
  126. if (!Style) Style=WS_CHILD|WS_VISIBLE|WS_TABSTOP|SS_BITMAP;
  127. A=CreateWindowEx(Exstyle,"static",NULL,Style,X*BCX_ScaleX,Y*BCX_ScaleY,0,0,hWnd,(HMENU)(HMENU)id,BCX_hInstance,NULL);
  128. // in case image is resource, fancier than needs to be
  129. if (Res)
  130. {
  131. hrlp=FindResource(BCX_hInstance,MAKEINTRESOURCE(Res),RT_RCDATA);
  132. if (hrlp!=0)
  133. {
  134. dwFileSize=SizeofResource(BCX_hInstance,hrlp);
  135. hGlobal=LoadResource(BCX_hInstance,hrlp);
  136. if (hGlobal!=0)
  137. {
  138. lpPicData=LockResource(hGlobal);
  139. pvData=NULL;
  140. hGlobal=GlobalAlloc(GMEM_MOVEABLE,dwFileSize);
  141. pvData=GlobalLock(hGlobal);
  142. CopyMemory(pvData,lpPicData,dwFileSize);
  143. GlobalUnlock(hGlobal);
  144. }
  145. }
  146. else
  147. return NULL;
  148. }
  149. else
  150. {
  151. hFile=CreateFile(szFile,GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL);
  152. dwFileSize=GetFileSize(hFile,NULL);
  153. if(dwFileSize==-1)
  154. return NULL;
  155. pvData=NULL;
  156. hGlobal=GlobalAlloc(GMEM_MOVEABLE,dwFileSize);
  157. pvData=GlobalLock(hGlobal);
  158. ReadFile(hFile,pvData,dwFileSize,&dwBytesRead,NULL);
  159. GlobalUnlock(hGlobal);
  160. CloseHandle(hFile);
  161. }
  162. CreateStreamOnHGlobal(hGlobal,TRUE,&pstm);
  163. OleLoadPicture(pstm,0,FALSE,&IID_IPicture,(LPVOID*)&gpPicture);
  164. pstm->lpVtbl->Release(pstm);
  165. gpPicture->lpVtbl->get_Handle(gpPicture,(OLE_HANDLE*)&hBitmap);
  166. if (W || H)
  167. hBitmap = CopyImage(hBitmap,IMAGE_BITMAP,W*BCX_ScaleX,H*BCX_ScaleY,LR_COPYRETURNORG);
  168. SendMessage(A,(UINT)STM_SETIMAGE,(WPARAM)IMAGE_BITMAP,(LPARAM)hBitmap);
  169. if (W || H)
  170. SetWindowPos(A,HWND_TOP,X*BCX_ScaleX,Y*BCX_ScaleY,W*BCX_ScaleX,H*BCX_ScaleY,SWP_DRAWFRAME);
  171. return A;
  172. }
  173.  
  174.  
  175. // details like title, corner coordinates,width,height,filename to load
  176. void FormLoad (void)
  177. {
  178. char filename[80];
  179.  
  180. Form1=BCX_Form("Display a JPEG from a file ... ",0,0,260,145);
  181.  
  182. // change filename to whatever image file you have!!!!!!!!!!!!!!!!!!!!!!!
  183. strcpy(filename,"Audi.jpg");
  184. if ( _access(filename,0) != 0)
  185. ExitProcess(0);
  186.  
  187. // width, height = 0,0 adjusts automatically to image
  188. Jpg1=BCX_OlePicture(filename,Form1,115,1,1,0,0);
  189. Show(Form1);
  190. }
  191.  
  192.  
  193. // message handler
  194. LRESULT CALLBACK WndProc (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
  195. {
  196. // cleanup and exit program
  197. if (Msg == WM_DESTROY)
  198. {
  199. UnregisterClass(BCX_ClassName,BCX_hInstance);
  200. PostQuitMessage(0);
  201. }
  202. return DefWindowProc(hWnd,Msg,wParam,lParam);
  203. }
  204.  
  205. and when i try to compile it it says that there is an undefined reference on the line (possibly 163) where it says IID_IPicture. how can i fix so i can see how this program works?
Cisnotforcookie is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Object reference error Jabo Visual Basic .NET 3 Oct 5th, 2007 2:37 AM
adding a reference to a file on the server paulchwd ASP.NET 1 Oct 2nd, 2007 11:25 PM
undefined reference J_I_M_B_O C 27 May 31st, 2006 4:59 PM
Getting a reference to an application nnxion C# 4 Apr 22nd, 2006 6:03 PM
Reseatable reference Klipt Show Off Your Open Source Projects 0 Feb 10th, 2006 1:26 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:00 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC